~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/charset.cc

  • Committer: Brian Aker
  • Date: 2009-02-09 17:09:52 UTC
  • Revision ID: brian@tangent.org-20090209170952-whoad9daa7707j5u
Remove THR_LOCK_charset  (we never recall it anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
#define MY_CHARSET_INDEX "Index.xml"
120
120
 
121
121
const char *charsets_dir= NULL;
122
 
static int charset_initialized=0;
 
122
static bool charset_initialized= false;
123
123
 
124
124
 
125
125
char *get_charsets_dir(char *buf)
163
163
    We have to use charset_initialized to not lock on THR_LOCK_charset
164
164
    inside get_internal_charset...
165
165
  */
166
 
  if (!charset_initialized)
 
166
  if (charset_initialized == false)
167
167
  {
168
168
    CHARSET_INFO **cs;
169
 
    /*
170
 
      To make things thread safe we are not allowing other threads to interfere
171
 
      while we may changing the cs_info_table
172
 
    */
173
 
    pthread_mutex_lock(&THR_LOCK_charset);
174
 
    if (!charset_initialized)
 
169
    memset(&all_charsets, 0, sizeof(all_charsets));
 
170
    init_compiled_charsets(myflags);
 
171
 
 
172
    /* Copy compiled charsets */
 
173
    for (cs=all_charsets;
 
174
         cs < all_charsets+array_elements(all_charsets)-1 ;
 
175
         cs++)
175
176
    {
176
 
      memset(&all_charsets, 0, sizeof(all_charsets));
177
 
      init_compiled_charsets(myflags);
178
 
 
179
 
      /* Copy compiled charsets */
180
 
      for (cs=all_charsets;
181
 
           cs < all_charsets+array_elements(all_charsets)-1 ;
182
 
           cs++)
 
177
      if (*cs)
183
178
      {
184
 
        if (*cs)
185
 
        {
186
 
          if (cs[0]->ctype)
187
 
            if (init_state_maps(*cs))
188
 
              *cs= NULL;
189
 
        }
 
179
        if (cs[0]->ctype)
 
180
          if (init_state_maps(*cs))
 
181
            *cs= NULL;
190
182
      }
191
 
 
192
 
      strcpy(get_charsets_dir(fname), MY_CHARSET_INDEX);
193
 
      charset_initialized=1;
194
183
    }
195
 
    pthread_mutex_unlock(&THR_LOCK_charset);
 
184
 
 
185
    strcpy(get_charsets_dir(fname), MY_CHARSET_INDEX);
 
186
    charset_initialized= true;
196
187
  }
 
188
  assert(charset_initialized);
 
189
 
197
190
  return error;
198
191
}
199
192
 
200
193
 
201
194
void free_charsets(void)
202
195
{
203
 
  charset_initialized=0;
 
196
  charset_initialized= true;
204
197
}
205
198
 
206
199
 
248
241
    To make things thread safe we are not allowing other threads to interfere
249
242
    while we may changing the cs_info_table
250
243
  */
251
 
  pthread_mutex_lock(&THR_LOCK_charset);
252
244
  if ((cs= all_charsets[cs_number]))
253
245
  {
254
246
    if (!(cs->state & MY_CS_COMPILED) && !(cs->state & MY_CS_LOADED))
265
257
    else
266
258
      cs->state|= MY_CS_READY;
267
259
  }
268
 
  pthread_mutex_unlock(&THR_LOCK_charset);
 
260
 
269
261
  return cs;
270
262
}
271
263