From 8969530cffde0c7a466cf3aa8c4b7462d0ace2d2 Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Sat, 12 Dec 2009 19:11:25 +0100 Subject: Bug #45058 init_available_charsets uses double checked locking As documented in the bug report, the double checked locking pattern has inherent issues, and cannot guarantee correct initialization. This patch replaces the logic in init_available_charsets() with the use of pthread_once(3). A wrapper function, my_pthread_once(), is introduced and is used in lieu of direct calls to init_available_charsets(). Related defines MY_PTHREAD_ONCE_* are also introduced. For the Windows platform, the implementation in lp:sysbench is ported. For single-thread use, a simple define calls the function and sets the pthread_once control variable. Charset initialization is modified to use my_pthread_once(). include/my_no_pthread.h: Dummy my_pthread_once() for single thread use. include/my_pthread.h: Declaration for new function my_pthread_once(). mysys/charset.c: Logic in init_available_charsets() is simplified. Using my_pthread_once() for all calls to this func. mysys/my_winthread.c: Windows implementation of my_pthread_once(). --- netware/libmysqlmain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'netware/libmysqlmain.c') diff --git a/netware/libmysqlmain.c b/netware/libmysqlmain.c index 03fdb832176..2b6ea9b7e27 100644 --- a/netware/libmysqlmain.c +++ b/netware/libmysqlmain.c @@ -18,7 +18,7 @@ #include "my_global.h" -my_bool init_available_charsets(myf myflags); +void init_available_charsets(void); /* this function is required so that global memory is allocated against this library nlm, and not against a paticular client */ @@ -31,7 +31,7 @@ int _NonAppStart(void *NLMHandle, void *errorScreen, const char *commandLine, { mysql_server_init(0, NULL, NULL); - init_available_charsets(MYF(0)); + init_available_charsets(); return 0; } -- cgit v1.2.1