1 ## fix-dummy-thread-race-condition.dpatch by <mkoegler@auto.tuwien.ac.at>
3 ## Avoid dummy thread for pthread_exit workaround
5 --- mysql-5.1.40/mysys/my_thr_init.c~ 2009-10-06 20:49:02.000000000 +0300
6 +++ mysql-5.1.40/mysys/my_thr_init.c 2009-10-27 15:01:59.807275693 +0200
8 pthread_mutexattr_t my_errorcheck_mutexattr;
11 -#ifdef TARGET_OS_LINUX
14 - Dummy thread spawned in my_thread_global_init() below to avoid
15 - race conditions in NPTL pthread_exit code.
18 -static pthread_handler_t
19 -nptl_pthread_exit_hack_handler(void *arg __attribute((unused)))
26 -#endif /* TARGET_OS_LINUX */
29 static uint get_thread_lib(void);
36 -#ifdef TARGET_OS_LINUX
38 - BUG#24507: Race conditions inside current NPTL pthread_exit()
41 - To avoid a possible segmentation fault during concurrent
42 - executions of pthread_exit(), a dummy thread is spawned which
43 - initializes internal variables of pthread lib. See bug description
44 - for a full explanation.
46 - TODO: Remove this code when fixed versions of glibc6 are in common
49 - if (thd_lib_detected == THD_LIB_NPTL)
51 - pthread_t dummy_thread;
52 - pthread_attr_t dummy_thread_attr;
54 - pthread_attr_init(&dummy_thread_attr);
55 - pthread_attr_setdetachstate(&dummy_thread_attr, PTHREAD_CREATE_JOINABLE);
57 - if (pthread_create(&dummy_thread,&dummy_thread_attr,
58 - nptl_pthread_exit_hack_handler, NULL) == 0)
59 - (void)pthread_join(dummy_thread, NULL);
61 -#endif /* TARGET_OS_LINUX */
63 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
65 Set mutex type to "fast" a.k.a "adaptive"