diff options
author | unknown <monty@mysql.com/narttu.mysql.fi> | 2006-11-30 18:25:05 +0200 |
---|---|---|
committer | unknown <monty@mysql.com/narttu.mysql.fi> | 2006-11-30 18:25:05 +0200 |
commit | 7191e775394db0392b78b07e2662c766eeace59c (patch) | |
tree | 66e16346c4fdfa20f915fdf53ea1f9419c07331c /mysys/my_thr_init.c | |
parent | 42fd48da99b2ba2641697ebb567af555fb270e9e (diff) | |
download | mariadb-git-7191e775394db0392b78b07e2662c766eeace59c.tar.gz |
Fixed portability issue in my_thr_init.c (was added in my last push)
Fixed compiler warnings (detected by VC++):
- Removed not used variables
- Added casts
- Fixed wrong assignments to bool
- Fixed wrong calls with bool arguments
- Added missing argument to store(longlong), which caused wrong store method to be called.
client/mysqldump.c:
Removed compiler warning
heap/hp_clear.c:
Removed compiler warning
include/my_global.h:
Removed compiler warning
include/my_tree.h:
Changed memory limits from int to ulong
(Allowed me to get rid of some compiler warnings)
myisam/mi_create.c:
Removed compiler warning
myisam/myisampack.c:
Removed compiler warning
mysys/base64.c:
Removed compiler warning
mysys/my_thr_init.c:
Fixed portability issue (detected on windows)
Added DBUG_ASSERT to detect if we call my_thread_end() too many times
Don't wait if THR_thread_count == -1 (error condition)
mysys/tree.c:
Removed compiler warning
sql/field.cc:
Removed compiler warning
Fixed wrong parameter to check_date()
Added missing argument to store(longlong)
sql/ha_archive.cc:
Removed compiler warning
sql/ha_federated.cc:
Removed compiler warning
sql/ha_innodb.cc:
Removed not used variable
sql/handler.cc:
Removed not used variable
Fixed wrong if (we didn't detect if rollback or commit failed). Not critical as value is not yet used
sql/item.cc:
Removed compiler warning
sql/item_func.cc:
Removed compiler warning
sql/item_strfunc.cc:
Removed compiler warning
sql/item_timefunc.cc:
Removed compiler warning
sql/log.cc:
Removed compiler warning
sql/mysql_priv.h:
Removed compiler warning
sql/opt_range.cc:
Removed compiler warning
sql/password.c:
Removed compiler warning
sql/set_var.cc:
Removed compiler warning
sql/slave.cc:
Removed compiler warning
sql/sp.cc:
Removed compiler warning
sql/sp_cache.cc:
Removed compiler warning
sql/sp_head.cc:
Removed compiler warning
Adjusted argument to reserve() to not use up too much memory that we are probably not going to need
sql/sql_acl.cc:
Added missing argument to store(longlong)
sql/sql_base.cc:
Removed compiler warning
sql/sql_db.cc:
Removed compiler warning
sql/sql_delete.cc:
Removed compiler warning
sql/sql_handler.cc:
Removed not used variable
sql/sql_lex.h:
Removed not used variable
sql/sql_prepare.cc:
Removed not used variable
sql/sql_rename.cc:
Removed not used variable
sql/sql_select.cc:
Fixed that select_options are not 'cut'
Removed some not used variables
Removed compiler warnings by adding cast
sql/sql_show.cc:
Removed not used variables
Added missing argument to store(longlong)
Removed compiler warnings
sql/sql_trigger.cc:
Removed not used variables
Added cast to remove compiler warnings
sql/sql_update.cc:
Fixed wrong set of bool variable
sql/sql_view.cc:
Removed not used variables
Added cast to get rid of compiler warnings
sql-common/client.c:
Fixed compiler warning
sql-common/my_time.c:
Fixed wrong argument to check_date()
Added casts to get rid of compiler warnings
sql/sql_yacc.yy:
Removed not used variable
sql/uniques.cc:
Changes memory size from uint to ulong
Added casts to get rid of compiler warnings
strings/ctype-simple.c:
Fixed cast to get rid of compiler warnings
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r-- | mysys/my_thr_init.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 7800edd700d..0e921bbe8a0 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -120,20 +120,21 @@ my_bool my_thread_global_init(void) void my_thread_global_end(void) { struct timespec abstime; - set_timespec(abstime, my_thread_end_wait_time); my_bool all_threads_killed= 1; + set_timespec(abstime, my_thread_end_wait_time); pthread_mutex_lock(&THR_LOCK_threads); - while (THR_thread_count) + while (THR_thread_count > 0) { int error= pthread_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads, &abstime); if (error == ETIMEDOUT || error == ETIME) { if (THR_thread_count) - fprintf(stderr,"error in my_thread_global_end(): %d threads didn't exit\n", + fprintf(stderr,"Error in my_thread_global_end(): %d threads didn't exit\n", THR_thread_count); all_threads_killed= 0; + break; } } pthread_mutex_unlock(&THR_LOCK_threads); @@ -228,10 +229,11 @@ void my_thread_end(void) { struct st_my_thread_var *tmp; tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); + DBUG_ASSERT(tmp); #ifdef EXTRA_DEBUG_THREADS - fprintf(stderr,"my_thread_end(): tmp=%p,thread_id=%ld\n", - tmp,pthread_self()); + fprintf(stderr,"my_thread_end(): tmp: 0x%lx thread_id=%ld\n", + (long) tmp, pthread_self()); #endif if (tmp && tmp->init) { @@ -253,15 +255,24 @@ void my_thread_end(void) #else tmp->init= 0; #endif + + /* + Decrement counter for number of running threads. We are using this + in my_thread_global_end() to wait until all threads have called + my_thread_end and thus freed all memory they have allocated in + my_thread_init() and DBUG_xxxx + */ + pthread_mutex_lock(&THR_LOCK_threads); + DBUG_ASSERT(THR_thread_count != 0); + if (--THR_thread_count == 0) + pthread_cond_signal(&THR_COND_threads); + pthread_mutex_unlock(&THR_LOCK_threads); } /* The following free has to be done, even if my_thread_var() is 0 */ #if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS) pthread_setspecific(THR_KEY_mysys,0); #endif - pthread_mutex_lock(&THR_LOCK_threads); - if (--THR_thread_count == 0) - pthread_cond_signal(&THR_COND_threads); - pthread_mutex_unlock(&THR_LOCK_threads); + } struct st_my_thread_var *_my_thread_var(void) |