diff options
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r-- | mysys/my_thr_init.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 0bd542d2bd9..8e6fdbbbec5 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -105,6 +105,8 @@ static long thread_id=0; my_bool my_thread_init(void) { struct st_my_thread_var *tmp; + my_bool error=0; + #ifdef EXTRA_DEBUG_THREADS fprintf(stderr,"my_thread_init(): thread_id=%ld\n",pthread_self()); #endif @@ -117,16 +119,14 @@ my_bool my_thread_init(void) { #ifdef EXTRA_DEBUG fprintf(stderr,"my_thread_init() called more than once in thread %ld\n", - pthread_self()); + pthread_self()); #endif - pthread_mutex_unlock(&THR_LOCK_lock); - return 0; /* Safequard */ + goto end; } - if (!(tmp=(struct st_my_thread_var *) - calloc(1, sizeof(struct st_my_thread_var)))) + if (!(tmp= (struct st_my_thread_var *) calloc(1, sizeof(*tmp)))) { - pthread_mutex_unlock(&THR_LOCK_lock); - return 1; + error= 1; + goto end; } pthread_setspecific(THR_KEY_mysys,tmp); @@ -146,7 +146,7 @@ end: #if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX) pthread_mutex_unlock(&THR_LOCK_lock); #endif - return 0; + return error; } void my_thread_end(void) |