diff options
author | monty@mysql.com <> | 2005-07-26 17:55:58 +0300 |
---|---|---|
committer | monty@mysql.com <> | 2005-07-26 17:55:58 +0300 |
commit | 4098c40d87ac11fe5043061f16a95a455376a782 (patch) | |
tree | 91bfa7092c665b2c4842cc67bff19a328d434aa4 | |
parent | d9bacfa236ceaf1b91caf6197122ad01ad8bfe37 (diff) | |
download | mariadb-git-4098c40d87ac11fe5043061f16a95a455376a782.tar.gz |
Review fixes:
Fixed portability problem with bool in C programs
Moved close_thread_tables out from LOCK_thread_count mutex (safety fix)
my_sleep() -> pthread_cond_timedwait()
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | include/thr_lock.h | 2 | ||||
-rw-r--r-- | mysys/thr_lock.c | 4 | ||||
-rw-r--r-- | sql/lock.cc | 20 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/slave.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 26 |
7 files changed, 38 insertions, 20 deletions
diff --git a/.bzrignore b/.bzrignore index 1d14c09a602..9f57a7ad7de 100644 --- a/.bzrignore +++ b/.bzrignore @@ -546,3 +546,4 @@ vio/viotest-ssl scripts/make_win_binary_distribution EXCEPTIONS-CLIENT support-files/my-innodb-heavy-4G.cnf +ac_available_languages_fragment diff --git a/include/thr_lock.h b/include/thr_lock.h index 8caaa112605..1062a49472b 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -107,7 +107,7 @@ void thr_unlock(THR_LOCK_DATA *data); int thr_multi_lock(THR_LOCK_DATA **data,uint count); void thr_multi_unlock(THR_LOCK_DATA **data,uint count); void thr_abort_locks(THR_LOCK *lock); -bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread); +my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread); void thr_print_locks(void); /* For debugging */ my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data); my_bool thr_reschedule_write_lock(THR_LOCK_DATA *data); diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 63dbe67c68e..a789162a56a 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -966,10 +966,10 @@ void thr_abort_locks(THR_LOCK *lock) This is used to abort all locks for a specific thread */ -bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread) +my_bool thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread) { THR_LOCK_DATA *data; - bool found= FALSE; + my_bool found= FALSE; DBUG_ENTER("thr_abort_locks_for_thread"); pthread_mutex_lock(&lock->mutex); diff --git a/sql/lock.cc b/sql/lock.cc index eb49254215d..47ccc44952d 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -331,7 +331,18 @@ void mysql_lock_abort(THD *thd, TABLE *table) } -/* Abort one thread / table combination */ +/* + Abort one thread / table combination + + SYNOPSIS + mysql_lock_abort_for_thread() + thd Thread handler + table Table that should be removed from lock queue + + RETURN + 0 Table was not locked by another thread + 1 Table was locked by at least one other thread +*/ bool mysql_lock_abort_for_thread(THD *thd, TABLE *table) { @@ -344,10 +355,9 @@ bool mysql_lock_abort_for_thread(THD *thd, TABLE *table) { for (uint i=0; i < locked->lock_count; i++) { - bool found; - found= thr_abort_locks_for_thread(locked->locks[i]->lock, - table->in_use->real_id); - result|= found; + if (thr_abort_locks_for_thread(locked->locks[i]->lock, + table->in_use->real_id)) + result= TRUE; } my_free((gptr) locked,MYF(0)); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index bc7ec53ccd9..9b9edd905ad 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -606,12 +606,15 @@ bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db, const char *table_name); void remove_db_from_cache(const my_string db); void flush_tables(); + +/* bits for last argument to remove_table_from_cache() */ #define RTFC_NO_FLAG 0x0000 #define RTFC_OWNED_BY_THD_FLAG 0x0001 #define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002 #define RTFC_CHECK_KILLED_FLAG 0x0004 bool remove_table_from_cache(THD *thd, const char *db, const char *table, uint flags); + bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables); void copy_field_from_tmp_record(Field *field,int offset); int fill_record(List<Item> &fields,List<Item> &values, bool ignore_errors); diff --git a/sql/slave.cc b/sql/slave.cc index 6132d334dbb..5e3d073b38a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2719,9 +2719,9 @@ err: mi->abort_slave = 0; // TODO: check if this is needed DBUG_ASSERT(thd->net.buff != 0); net_end(&thd->net); // destructor will not free it, because net.vio is 0 + close_thread_tables(thd, 0); pthread_mutex_lock(&LOCK_thread_count); THD_CHECK_SENTRY(thd); - close_thread_tables(thd); delete thd; pthread_mutex_unlock(&LOCK_thread_count); pthread_cond_broadcast(&mi->stop_cond); // tell the world we are done diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 32d14854e08..7d3bb81793a 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2403,8 +2403,14 @@ void flush_tables() /* -** Mark all entries with the table as deleted to force an reopen of the table -** Returns true if the table is in use by another thread + Mark all entries with the table as deleted to force an reopen of the table + + PREREQUISITES + Lock on LOCK_open() + + RETURN + 0 If the table is NOT in use by another thread + 1 If the table is NOT in use by another thread */ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, @@ -2416,6 +2422,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, bool result=0, signalled= 0; DBUG_ENTER("remove_table_from_cache"); + key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1; for (;;) { @@ -2473,15 +2480,12 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, { if (!(flags & RTFC_CHECK_KILLED_FLAG) || !thd->killed) { + dropping_tables++; if (likely(signalled)) - { - dropping_tables++; (void) pthread_cond_wait(&COND_refresh, &LOCK_open); - dropping_tables--; - continue; - } else { + struct timespec abstime; /* It can happen that another thread has opened the table but has not yet locked any table at all. Since @@ -2492,11 +2496,11 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, and then we retry another loop in the remove_table_from_cache routine. */ - pthread_mutex_unlock(&LOCK_open); - my_sleep(10); - pthread_mutex_lock(&LOCK_open); - continue; + set_timespec(abstime, 10); + pthread_cond_timedwait(&COND_refresh, &LOCK_open, &abstime); } + dropping_tables--; + continue; } } break; |