X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ftime%2Ftimer_create.c;h=5d362c7ed7e626cce1dde6c37df383894789ebd0;hb=6f1414e10297b75a58a92b678444fd277abc9a4f;hp=c5894f48060f195e5d16e99a4636f1cd28565ab0;hpb=3990c5c6a40440cdb14746ac080d0ecf8d5d6733;p=musl diff --git a/src/time/timer_create.c b/src/time/timer_create.c index c5894f48..5d362c7e 100644 --- a/src/time/timer_create.c +++ b/src/time/timer_create.c @@ -13,10 +13,9 @@ struct start_args { struct sigevent *sev; }; -static void sighandler(int sig, siginfo_t *si, void *ctx) +void __sigtimer_handler(pthread_t self) { int st; - pthread_t self = __pthread_self(); void (*notify)(union sigval) = (void (*)(union sigval))self->start; union sigval val = { .sival_ptr = self->start_arg }; @@ -25,6 +24,12 @@ static void sighandler(int sig, siginfo_t *si, void *ctx) pthread_setcancelstate(st, 0); } +static void cleanup(void *p) +{ + pthread_t self = p; + __syscall(SYS_timer_delete, self->result); +} + static void *start(void *arg) { pthread_t self = __pthread_self(); @@ -36,10 +41,12 @@ static void *start(void *arg) self->start_arg = args->sev->sigev_value.sival_ptr; self->result = (void *)-1; + pthread_cleanup_push(cleanup, self); pthread_barrier_wait(&args->b); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); /* Loop on async-signal-safe cancellation point */ for (;;) sleep(1); + pthread_cleanup_pop(0); return 0; } @@ -72,7 +79,6 @@ int timer_create(clockid_t clk, struct sigevent *evp, timer_t *res) *res = (void *)(2*timerid+1); break; case SIGEV_THREAD: - if (!libc.sigtimer) libc.sigtimer = sighandler; if (sev.sigev_notify_attributes) attr = *sev.sigev_notify_attributes; else