From: Arran Cudbard-Bell Date: Mon, 19 Sep 2016 09:52:47 +0000 (+0400) Subject: Call pthread_setspecific for every thread that calls fr_thread_local_init, not just... X-Git-Tag: release_3_0_12~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5892b07237a43a990bb15d504e4c51ba836c420;p=thirdparty%2Ffreeradius-server.git Call pthread_setspecific for every thread that calls fr_thread_local_init, not just the first one. Otherwise, the value associated with the key is NULL and the destructor isn't called. --- diff --git a/src/include/threads.h b/src/include/threads.h index 63703b77726..e36d81dac00 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -75,13 +75,13 @@ static void __fr_thread_local_destroy_##_n(UNUSED void *unused)\ static void __fr_thread_local_key_init_##_n(void)\ {\ (void) pthread_key_create(&__fr_thread_local_key_##_n, __fr_thread_local_destroy_##_n);\ - (void) pthread_setspecific(__fr_thread_local_key_##_n, &(_n));\ }\ static _t __fr_thread_local_init_##_n(pthread_destructor_t func)\ {\ __fr_thread_local_destructor_##_n = func;\ if (_n) return _n; \ (void) pthread_once(&__fr_thread_local_once_##_n, __fr_thread_local_key_init_##_n);\ + (void) pthread_setspecific(__fr_thread_local_key_##_n, &(_n));\ return _n;\ } # define fr_thread_local_init(_n, _f) __fr_thread_local_init_##_n(_f)