Call pthread_setspecific for every thread that calls fr_thread_local_init, not just...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 19 Sep 2016 09:52:47 +0000 (13:52 +0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 19 Sep 2016 09:53:13 +0000 (13:53 +0400)
src/include/threads.h

index 63703b7..e36d81d 100644 (file)
@@ -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)