X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;ds=sidebyside;f=src%2Fthreads.h;h=85aaced7ecc843f5cdf0b2c998660ab22a979139;hb=6834b882015a9323672e9fce8811aa4283f196f0;hp=d2ef4a640c7766bd6d00176dd89aca108f76ca9e;hpb=b107b10c4ef70bdf74d6d6ac57ff5ab2698b9cb2;p=tinc diff --git a/src/threads.h b/src/threads.h index d2ef4a64..85aaced7 100644 --- a/src/threads.h +++ b/src/threads.h @@ -32,11 +32,16 @@ static inline bool thread_create(thread_t *tid, void (*func)(void *), void *arg) return !pthread_create(tid, NULL, (void *(*)(void *))func, arg); } static inline void thread_destroy(thread_t *tid) { + pthread_cancel(*tid); pthread_join(*tid, NULL); } static inline void mutex_create(mutex_t *mutex) { pthread_mutex_init(mutex, NULL); } +#if 1 +#define mutex_lock(m) logger(LOG_DEBUG, "mutex_lock() at " __FILE__ " line %d", __LINE__); pthread_mutex_lock(m) +#define mutex_unlock(m) logger(LOG_DEBUG, "mutex_unlock() at " __FILE__ " line %d", __LINE__); pthread_mutex_unlock(m) +#else static inline void mutex_lock(mutex_t *mutex) { pthread_mutex_lock(mutex); } @@ -44,5 +49,6 @@ static inline void mutex_unlock(mutex_t *mutex) { pthread_mutex_unlock(mutex); } #endif +#endif #endif