Commit 600a2836 authored by Staale Smedseng's avatar Staale Smedseng

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().
parent ca669153
...@@ -950,7 +950,7 @@ extern my_bool resolve_charset(const char *cs_name, ...@@ -950,7 +950,7 @@ extern my_bool resolve_charset(const char *cs_name,
extern my_bool resolve_collation(const char *cl_name, extern my_bool resolve_collation(const char *cl_name,
CHARSET_INFO *default_cl, CHARSET_INFO *default_cl,
CHARSET_INFO **cl); CHARSET_INFO **cl);
extern void free_charsets(void);
extern char *get_charsets_dir(char *buf); extern char *get_charsets_dir(char *buf);
extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
extern my_bool init_compiled_charsets(myf flags); extern my_bool init_compiled_charsets(myf flags);
......
...@@ -211,6 +211,7 @@ void STDCALL mysql_server_end() ...@@ -211,6 +211,7 @@ void STDCALL mysql_server_end()
} }
else else
{ {
free_charsets();
mysql_thread_end(); mysql_thread_end();
} }
......
...@@ -427,6 +427,11 @@ static void init_available_charsets(void) ...@@ -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) uint get_collation_number(const char *name)
{ {
my_pthread_once(&charsets_initialized, init_available_charsets); my_pthread_once(&charsets_initialized, init_available_charsets);
......
...@@ -165,6 +165,7 @@ void my_end(int infoflag) ...@@ -165,6 +165,7 @@ void my_end(int infoflag)
my_print_open_files(); my_print_open_files();
} }
} }
free_charsets();
my_error_unregister_all(); my_error_unregister_all();
my_once_free(); my_once_free();
......
...@@ -1287,6 +1287,7 @@ void clean_up(bool print_message) ...@@ -1287,6 +1287,7 @@ void clean_up(bool print_message)
lex_free(); /* Free some memory */ lex_free(); /* Free some memory */
item_create_cleanup(); item_create_cleanup();
set_var_free(); set_var_free();
free_charsets();
if (!opt_noacl) if (!opt_noacl)
{ {
#ifdef HAVE_DLOPEN #ifdef HAVE_DLOPEN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment