summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMagnus Blåudd <magnus.blaudd@sun.com>2009-09-24 08:30:31 +0200
committerMagnus Blåudd <magnus.blaudd@sun.com>2009-09-24 08:30:31 +0200
commit9eab1cdb9ae94120dd35aeee13c13295ba59ee3b (patch)
tree61d540c66d3d8c805a41e369b3f9e3870dc31ee3 /mysys
parentf280974393b70cbe13f96bee2a79bfd0a625906f (diff)
downloadmariadb-git-9eab1cdb9ae94120dd35aeee13c13295ba59ee3b.tar.gz
Bug#42850 race condition in my_thr_init.c
- Create the "dummy" thread joinable and wait for it to exit before continuing in 'my_thread_global_init' - This way we know that the pthread library is initialized by one thread only
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_thr_init.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index c446808c7da..64fc99952e9 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -107,10 +107,11 @@ my_bool my_thread_global_init(void)
pthread_attr_t dummy_thread_attr;
pthread_attr_init(&dummy_thread_attr);
- pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_DETACHED);
+ pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_JOINABLE);
- pthread_create(&dummy_thread,&dummy_thread_attr,
- nptl_pthread_exit_hack_handler, NULL);
+ if (pthread_create(&dummy_thread,&dummy_thread_attr,
+ nptl_pthread_exit_hack_handler, NULL) == 0)
+ (void)pthread_join(dummy_thread, NULL);
}
#endif /* TARGET_OS_LINUX */