From 02eff258c6a39746db287e20c142153e80c81bac Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 17 Apr 2011 12:15:55 -0400 Subject: [PATCH] don't use pthread_once when there is no danger in race --- src/thread/cancel_impl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/thread/cancel_impl.c b/src/thread/cancel_impl.c index 28dc84dc..7bcfaef5 100644 --- a/src/thread/cancel_impl.c +++ b/src/thread/cancel_impl.c @@ -71,8 +71,11 @@ static void init_cancellation() int pthread_cancel(pthread_t t) { - static pthread_once_t once; - pthread_once(&once, init_cancellation); + static int init; + if (!init) { + init_cancellation(); + init = 1; + } a_store(&t->cancel, 1); return pthread_kill(t, SIGCANCEL); }