diff options
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 930a176f6fa..45b99bfee1b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4082,6 +4082,9 @@ void flush_tables() The table will be closed (not stored in cache) by the current thread when close_thread_tables() is called. + PREREQUISITES + Lock on LOCK_open() + RETURN 0 This thread now have exclusive access to this table and no other thread can access the table until close_thread_tables() is called. @@ -4097,6 +4100,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 (;;) { @@ -4154,15 +4158,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 @@ -4173,11 +4174,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; |