summaryrefslogtreecommitdiff
path: root/mysys/charset.c
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-07-25 21:34:20 +0500
committerunknown <bar@mysql.com>2005-07-25 21:34:20 +0500
commita6b225ba8d20b20cab6f32176693980504965ab0 (patch)
treef0e138cff573db9a514e20b96ffb68eb1dc1e26d /mysys/charset.c
parentbdc0c6719569e9a5224105c4a15d24d416f36017 (diff)
downloadmariadb-git-a6b225ba8d20b20cab6f32176693980504965ab0.tar.gz
charset.c:
Bug#12109 possible locking bug in init_available_charset Recheck charset_initialized inside locked code, to garantee two threads are not entering consequently. mysys/charset.c: Bug#12109 possible locking bug in init_available_charset Recheck charset_initialized inside locked code, to garantee two threads are not entering consequently.
Diffstat (limited to 'mysys/charset.c')
-rw-r--r--mysys/charset.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index 4b7ad3e59f4..cabdbad3413 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -383,26 +383,28 @@ static my_bool init_available_charsets(myf myflags)
while we may changing the cs_info_table
*/
pthread_mutex_lock(&THR_LOCK_charset);
-
- bzero(&all_charsets,sizeof(all_charsets));
- init_compiled_charsets(myflags);
-
- /* Copy compiled charsets */
- for (cs=all_charsets;
- cs < all_charsets+array_elements(all_charsets)-1 ;
- cs++)
+ if (!charset_initialized)
{
- if (*cs)
+ bzero(&all_charsets,sizeof(all_charsets));
+ init_compiled_charsets(myflags);
+
+ /* Copy compiled charsets */
+ for (cs=all_charsets;
+ cs < all_charsets+array_elements(all_charsets)-1 ;
+ cs++)
{
- if (cs[0]->ctype)
- if (init_state_maps(*cs))
- *cs= NULL;
+ if (*cs)
+ {
+ if (cs[0]->ctype)
+ if (init_state_maps(*cs))
+ *cs= NULL;
+ }
}
+
+ strmov(get_charsets_dir(fname), MY_CHARSET_INDEX);
+ error= my_read_charset_file(fname,myflags);
+ charset_initialized=1;
}
-
- strmov(get_charsets_dir(fname), MY_CHARSET_INDEX);
- error= my_read_charset_file(fname,myflags);
- charset_initialized=1;
pthread_mutex_unlock(&THR_LOCK_charset);
}
return error;