diff --git a/daemon/load.c b/daemon/load.c index a878a0bc1..b12e72128 100644 --- a/daemon/load.c +++ b/daemon/load.c @@ -52,8 +52,8 @@ void load_thread(void *dummy) { } } - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + thread_cancel_enable(); usleep(500000); - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); + thread_cancel_disable(); } } diff --git a/daemon/main.c b/daemon/main.c index 016a29d46..5a08a9d76 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -119,9 +119,9 @@ static void sighandler(gpointer x) { ts.tv_nsec = 0; while (!rtpe_shutdown) { - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + thread_cancel_enable(); ret = sigtimedwait(&ss, NULL, &ts); - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); + thread_cancel_disable(); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) diff --git a/daemon/poller.c b/daemon/poller.c index e17a0b087..be6f73adb 100644 --- a/daemon/poller.c +++ b/daemon/poller.c @@ -388,9 +388,9 @@ int poller_poll(struct poller *p, int timeout) { mutex_unlock(&p->lock); errno = 0; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + thread_cancel_enable(); ret = epoll_wait(p->fd, evs, sizeof(evs) / sizeof(*evs), timeout); - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); + thread_cancel_disable(); mutex_lock(&p->lock); if (errno == EINTR) @@ -585,9 +585,9 @@ void poller_timer_loop(void *d) { if (sleeptime <= 0) goto now; - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + thread_cancel_enable(); usleep(sleeptime); - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); + thread_cancel_disable(); continue; diff --git a/include/aux.h b/include/aux.h index e3c244c0e..1092bd334 100644 --- a/include/aux.h +++ b/include/aux.h @@ -349,6 +349,9 @@ INLINE void thread_create_detach(void (*f)(void *), void *a, const char *name) { thread_create_detach_prio(f, a, NULL, 0, name); } +#define thread_cancel_enable() pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) +#define thread_cancel_disable() pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) +