X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fthreads.h;h=3ec8c681aec1d60ffb6d6cba67fd2c6606a4ce3d;hb=288990c809f818ccb87d04234b783efd0a2c0276;hp=d55e59ed9eb3f7c15051b470b284fb36dca6bd12;hpb=fac60c692a5f838bec7498f13db872774f1ea717;p=tinc diff --git a/src/threads.h b/src/threads.h index d55e59ed..3ec8c681 100644 --- a/src/threads.h +++ b/src/threads.h @@ -29,7 +29,14 @@ typedef pthread_t thread_t; typedef pthread_mutex_t mutex_t; static inline bool thread_create(thread_t *tid, void (*func)(void *), void *arg) { - return !pthread_create(tid, NULL, (void *(*)(void *))func, arg); + bool result; + + sigset_t old, block; + sigfillset(&block); + pthread_sigmask(SIG_SETMASK, &block, &old); + result = pthread_create(tid, NULL, (void *(*)(void *))func, arg); + pthread_sigmask(SIG_SETMASK, &old, NULL); + return !result; } static inline void thread_destroy(thread_t *tid) { pthread_cancel(*tid); @@ -38,6 +45,10 @@ static inline void thread_destroy(thread_t *tid) { 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); } @@ -45,5 +56,6 @@ static inline void mutex_unlock(mutex_t *mutex) { pthread_mutex_unlock(mutex); } #endif +#endif #endif