Browse Source

MT#56374 refactor asan pthread cleanup hack

... in terms of macros that can be reused.

Change-Id: I394dece8ec22ce4eff4deefe5ddd6315bb35a6fb
pull/1701/head
Richard Fuchs 2 years ago
parent
commit
196249ee00
3 changed files with 8 additions and 10 deletions
  1. +2
    -8
      daemon/helpers.c
  2. +4
    -0
      lib/auxlib.h
  3. +2
    -2
      recording-daemon/epoll.c

+ 2
- 8
daemon/helpers.c View File

@ -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;
}


+ 4
- 0
lib/auxlib.h View File

@ -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


+ 2
- 2
recording-daemon/epoll.c View File

@ -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;
}


Loading…
Cancel
Save