summaryrefslogtreecommitdiff
path: root/sql/rpl_mi.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r--sql/rpl_mi.cc29
1 files changed, 17 insertions, 12 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index e90557efd0d..43c5eceecf4 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -1557,6 +1557,9 @@ bool give_error_if_slave_running(bool already_locked)
/**
any_slave_sql_running()
+ @param
+ already_locked 0 if we need to lock, 1 if we have LOCK_active_mi_locked
+
@return
0 No Slave SQL thread is running
# Number of slave SQL thread running
@@ -1567,26 +1570,28 @@ bool give_error_if_slave_running(bool already_locked)
hash entries can't be accessed.
*/
-uint any_slave_sql_running()
+uint any_slave_sql_running(bool already_locked)
{
uint count= 0;
HASH *hash;
DBUG_ENTER("any_slave_sql_running");
- mysql_mutex_lock(&LOCK_active_mi);
+ if (!already_locked)
+ mysql_mutex_lock(&LOCK_active_mi);
if (unlikely(shutdown_in_progress || !master_info_index))
+ count= 1;
+ else
{
- mysql_mutex_unlock(&LOCK_active_mi);
- DBUG_RETURN(1);
- }
- hash= &master_info_index->master_info_hash;
- for (uint i= 0; i< hash->records; ++i)
- {
- Master_info *mi= (Master_info *)my_hash_element(hash, i);
- if (mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN)
- count++;
+ hash= &master_info_index->master_info_hash;
+ for (uint i= 0; i< hash->records; ++i)
+ {
+ Master_info *mi= (Master_info *)my_hash_element(hash, i);
+ if (mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN)
+ count++;
+ }
}
- mysql_mutex_unlock(&LOCK_active_mi);
+ if (!already_locked)
+ mysql_mutex_unlock(&LOCK_active_mi);
DBUG_RETURN(count);
}