summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
authorunknown <sven@riska.(none)>2008-03-11 14:42:54 +0100
committerunknown <sven@riska.(none)>2008-03-11 14:42:54 +0100
commit1836625fb4e42b1629b59a4f070d6849da2ee434 (patch)
treeeb75e4674ea17a34c26f2564b59db9d5f3bde5f5 /sql/slave.cc
parent0e679ab782e6968b159bcca8cdf307e5602dd3ea (diff)
downloadmariadb-git-1836625fb4e42b1629b59a4f070d6849da2ee434.tar.gz
BUG#31024: STOP SLAVE does not stop attempted connect()s
Problem: if the IO slave thread is attempting to connect, STOP SLAVE waits for the attempt to finish. It may take a long time. Fix: don't wait, stop the slave immediately. sql/slave.cc: Send a SIGALRM signal to the slave thread when stopping it (using pthread_kill()). This breaks current socket(), connect(), poll() etc. calls, and makes the subsequent thd->awake() call effective. Also, move the definition of KICK_SLAVE to slave.cc. sql/sql_repl.h: Removed KICK_SLAVE and inlined it in slave.cc because: - it was only called once, so better to make it local to where it is used - it needed to include a preprocessor conditional in the middle
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index d4d0655f366..5488b3c312a 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -699,7 +699,20 @@ int terminate_slave_thread(THD* thd, pthread_mutex_t* term_lock,
while (*slave_running) // Should always be true
{
DBUG_PRINT("loop", ("killing slave thread"));
- KICK_SLAVE(thd);
+
+ pthread_mutex_lock(&thd->LOCK_delete);
+#ifndef DONT_USE_THR_ALARM
+ /*
+ Error codes from pthread_kill are:
+ EINVAL: invalid signal number (can't happen)
+ ESRCH: thread already killed (can happen, should be ignored)
+ */
+ IF_DBUG(int err= ) pthread_kill(thd->real_id, thr_client_alarm);
+ DBUG_ASSERT(err != EINVAL);
+#endif
+ thd->awake(THD::NOT_KILLED);
+ pthread_mutex_unlock(&thd->LOCK_delete);
+
/*
There is a small chance that slave thread might miss the first
alarm. To protect againts it, resend the signal until it reacts