diff options
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sql/log.cc b/sql/log.cc index aed30e2bb39..c81869a57e7 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3171,6 +3171,21 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_period) bzero((char*) &purge_index_file, sizeof(purge_index_file)); } +void MYSQL_BIN_LOG::stop_background_thread() +{ + if (binlog_background_thread_started) + { + mysql_mutex_lock(&LOCK_binlog_background_thread); + binlog_background_thread_stop= true; + mysql_cond_signal(&COND_binlog_background_thread); + while (binlog_background_thread_stop) + mysql_cond_wait(&COND_binlog_background_thread_end, + &LOCK_binlog_background_thread); + mysql_mutex_unlock(&LOCK_binlog_background_thread); + binlog_background_thread_started= false; + } +} + /* this is called only once */ void MYSQL_BIN_LOG::cleanup() @@ -3181,17 +3196,8 @@ void MYSQL_BIN_LOG::cleanup() xid_count_per_binlog *b; /* Wait for the binlog background thread to stop. */ - if (!is_relay_log && binlog_background_thread_started) - { - mysql_mutex_lock(&LOCK_binlog_background_thread); - binlog_background_thread_stop= true; - mysql_cond_signal(&COND_binlog_background_thread); - while (binlog_background_thread_stop) - mysql_cond_wait(&COND_binlog_background_thread_end, - &LOCK_binlog_background_thread); - mysql_mutex_unlock(&LOCK_binlog_background_thread); - binlog_background_thread_started= false; - } + if (!is_relay_log) + stop_background_thread(); inited= 0; close(LOG_CLOSE_INDEX|LOG_CLOSE_STOP_EVENT); |