return pthread_mutex_destroy(&m->mutex);
}
+/*
+ * Replacement for pthread_kill (only with USE_LOCKMGR_SAFEKILL)
+ */
+int bthread_kill(pthread_t thread, int sig,
+ const char *file, int line)
+{
+ bool thread_found_in_process=false;
+
+ /* We doesn't allow to send signal to ourself */
+ ASSERT(!pthread_equal(thread, pthread_self()));
+
+ /* This loop isn't very efficient with dozens of threads but we don't use
+ * signal very much, and this feature is for testing only
+ */
+ lmgr_p(&lmgr_global_mutex);
+ {
+ lmgr_thread_t *item;
+ foreach_dlist(item, global_mgr) {
+ if (pthread_equal(thread, item->thread_id)) {
+ thread_found_in_process=true;
+ break;
+ }
+ }
+ }
+ lmgr_v(&lmgr_global_mutex);
+
+ /* Sending a signal to non existing thread can create problem
+ * so, we can stop here.
+ */
+ ASSERT(thread_found_in_process == true);
+
+ return pthread_kill(thread, sig);
+}
+
/*
* Replacement for pthread_mutex_lock()
* Returns always ok
const pthread_attr_t *attr,
void *(*start_routine)(void*), void *arg);
+/*
+ * Can use SAFEKILL to check if the argument is a valid threadid
+ */
+int bthread_kill(pthread_t thread, int sig,
+ const char *file="*unknown*", int line=0);
+
+#ifdef USE_LOCKMGR_SAFEKILL
+# define pthread_kill(a,b) bthread_kill((a),(b), __FILE__, __LINE__)
+#endif
+
#define BTHREAD_MUTEX_NO_PRIORITY {PTHREAD_MUTEX_INITIALIZER, 0}
#define BTHREAD_MUTEX_INITIALIZER BTHREAD_MUTEX_NO_PRIORITY