From 600a28368916ae07c0694ae090dcba7f2c52b12a Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Fri, 26 Feb 2010 15:30:14 +0100 Subject: Bug #45058 init_available_charsets uses double checked locking A client doing multiple mysql_library_init() and mysql_library_end() calls over the lifetime of the process may experience lost character set data, potentially even a SIGSEGV. This patch reinstates the reloading of character set data when a mysql_library_init() is done after a mysql_library_end(). --- mysys/charset.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mysys/charset.c') diff --git a/mysys/charset.c b/mysys/charset.c index b1b91d716ba..584b33b2d6a 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -427,6 +427,11 @@ static void init_available_charsets(void) } +void free_charsets(void) +{ + charsets_initialized= MY_PTHREAD_ONCE_INIT; +} + uint get_collation_number(const char *name) { my_pthread_once(&charsets_initialized, init_available_charsets); -- cgit v1.2.1 From a3f59677f886a45e0d0b1b5cf0225966ecf6ee15 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 26 Feb 2010 23:09:36 -0300 Subject: Workaround the pthread_once_t static initialization. Per the POSIX standard, reinitialization of a pthread_once is a gray area, but it is needed to support subsequent initializations of the client library. mysys/charset.c: Reinitialize a pthread_once_t variable. --- mysys/charset.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mysys/charset.c') diff --git a/mysys/charset.c b/mysys/charset.c index 584b33b2d6a..9678febc9ba 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -400,6 +400,7 @@ static void *cs_alloc(size_t size) static my_pthread_once_t charsets_initialized= MY_PTHREAD_ONCE_INIT; +static my_pthread_once_t charsets_template= MY_PTHREAD_ONCE_INIT; static void init_available_charsets(void) { @@ -429,7 +430,7 @@ static void init_available_charsets(void) void free_charsets(void) { - charsets_initialized= MY_PTHREAD_ONCE_INIT; + charsets_initialized= charsets_template; } uint get_collation_number(const char *name) -- cgit v1.2.1