提交 6f1414e1 编写于 作者: R Rich Felker

revert to deleting kernel-level timer from cancellation handler

this is necessary in order to avoid breaking timer_getoverrun in the
last run of the timer event handler, if it has not yet finished.
上级 f01d3518
...@@ -24,6 +24,12 @@ void __sigtimer_handler(pthread_t self) ...@@ -24,6 +24,12 @@ void __sigtimer_handler(pthread_t self)
pthread_setcancelstate(st, 0); pthread_setcancelstate(st, 0);
} }
static void cleanup(void *p)
{
pthread_t self = p;
__syscall(SYS_timer_delete, self->result);
}
static void *start(void *arg) static void *start(void *arg)
{ {
pthread_t self = __pthread_self(); pthread_t self = __pthread_self();
...@@ -35,10 +41,12 @@ static void *start(void *arg) ...@@ -35,10 +41,12 @@ static void *start(void *arg)
self->start_arg = args->sev->sigev_value.sival_ptr; self->start_arg = args->sev->sigev_value.sival_ptr;
self->result = (void *)-1; self->result = (void *)-1;
pthread_cleanup_push(cleanup, self);
pthread_barrier_wait(&args->b); pthread_barrier_wait(&args->b);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
/* Loop on async-signal-safe cancellation point */ /* Loop on async-signal-safe cancellation point */
for (;;) sleep(1); for (;;) sleep(1);
pthread_cleanup_pop(0);
return 0; return 0;
} }
......
...@@ -3,11 +3,7 @@ ...@@ -3,11 +3,7 @@
int timer_delete(timer_t t) int timer_delete(timer_t t)
{ {
pthread_t td = 0; if ((uintptr_t)t & 1)
int r; return __syscall(SYS_timer_delete, ((unsigned long)t / 2));
if ((uintptr_t)t & 1) t = (void *)((unsigned long)t / 2); return pthread_cancel(t);
else td = t, t = td->result;
r = __syscall(SYS_timer_delete, (long)t);
if (td) pthread_cancel(td);
return r;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册