diff --git a/daemon/helpers.c b/daemon/helpers.c index 73c2bab7f..3ed605499 100644 --- a/daemon/helpers.c +++ b/daemon/helpers.c @@ -250,15 +250,9 @@ static void *thread_detach_func(void *d) { dt->priority, strerror(errno)); } -#ifndef ASAN_BUILD - pthread_cleanup_push(thread_detach_cleanup, dt); -#endif + thread_cleanup_push(thread_detach_cleanup, dt); dt->func(dt->data); -#ifndef ASAN_BUILD - pthread_cleanup_pop(true); -#else - thread_detach_cleanup(dt); -#endif + thread_cleanup_pop(true); return NULL; } diff --git a/lib/auxlib.h b/lib/auxlib.h index b668eaea9..191421f10 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -132,10 +132,14 @@ INLINE int __cond_timedwait_tv(cond_t *c, mutex_t *m, const struct timeval *tv) #define thread_cancel_enable() pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) #define thread_cancel_disable() pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) #define thread_sleep_time 10000 /* ms */ +#define thread_cleanup_push pthread_cleanup_push +#define thread_cleanup_pop pthread_cleanup_pop #else #define thread_cancel_enable() ((void)0) #define thread_cancel_disable() ((void)0) #define thread_sleep_time 100 /* ms */ +#define thread_cleanup_push(f,a) void (*_cfn)(void *) = f; void *_cfa = a +#define thread_cleanup_pop(exe) assert(exe != false); _cfn(_cfa) #endif diff --git a/recording-daemon/epoll.c b/recording-daemon/epoll.c index c679717d7..6ae6b102e 100644 --- a/recording-daemon/epoll.c +++ b/recording-daemon/epoll.c @@ -47,7 +47,7 @@ void *poller_thread(void *ptr) { mysql_thread_init(); - pthread_cleanup_push(poller_thread_end, NULL); + thread_cleanup_push(poller_thread_end, NULL); while (!shutdown_flag) { pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); @@ -70,7 +70,7 @@ void *poller_thread(void *ptr) { garbage_collect(me_num); } - pthread_cleanup_pop(1); + thread_cleanup_pop(true); return NULL; }