mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] time: Fix bug in timer_create
@ 2019-09-24 11:16 changdiankang
  2019-09-25 17:19 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: changdiankang @ 2019-09-24 11:16 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

time: Fix bug in timer_create

When create a SIGEV_THREAD timer, in helper thread "start",
"id" is assigned with self->timer_id immediately after pthread_create.
But the real timer_id is assigned to self->timer_id after SYS_timer_create.
So "id" in "start" always be 0, and timer_delete will always fail.
Put assignement of "id" after pthread_barrier_wait can fix this bug.

Signed-off-by: Chang Diankang <changdiankang@huawei.com<mailto:changdiankang@huawei.com>>

diff --git a/src/time/timer_create.c b/src/time/timer_create.c
index c5e40a1..4172b9e 100644
--- a/src/time/timer_create.c
+++ b/src/time/timer_create.c
@@ -48,13 +48,14 @@ static void *start(void *arg)
{
        pthread_t self = __pthread_self();
        struct start_args *args = arg;
-       int id = self->timer_id;
+       int id;
        jmp_buf jb;

        void (*notify)(union sigval) = args->sev->sigev_notify_function;
        union sigval val = args->sev->sigev_value;

        pthread_barrier_wait(&args->b);
+       id = self->timer_id;
        for (;;) {
                siginfo_t si;
                while (sigwaitinfo(SIGTIMER_SET, &si) < 0);


[-- Attachment #2: Type: text/html, Size: 4729 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-26  3:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-24 11:16 [PATCH] time: Fix bug in timer_create changdiankang
2019-09-25 17:19 ` Rich Felker
2019-09-25 17:34   ` Rich Felker
2019-09-26  3:41     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).