diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-08-15 15:41:52 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-08-15 15:41:52 -0600 |
commit | 2ddd23f624ce54aaa30077d946a4bbc8d9fe2072 (patch) | |
tree | f80ff6a7e307b47fb9ab596e0929cbd50a50d0b7 /sql/sql_repl.cc | |
parent | 48656d8ba86dce47867f2a51c8212f48c05088b9 (diff) | |
download | mariadb-git-2ddd23f624ce54aaa30077d946a4bbc8d9fe2072.tar.gz |
improvements for stopping the slave in SLAVE STOP and on shutdown
sql/mini_client.cc:
alarm around mc_mysql_connect()
sql/mysqld.cc:
move end_slave() to the earlier part of shutdown
sql/sql_repl.cc:
retry thr_alarm_kill() in case slave thread missed the signal in SLAVE STOP
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 3cb805ed796..32c4c5c6509 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -610,8 +610,26 @@ int stop_slave(THD* thd, bool net_report ) // do not abort the slave in the middle of a query, so we do not set // thd->killed for the slave thread thd->proc_info = "waiting for slave to die"; - while(slave_running) - pthread_cond_wait(&COND_slave_stopped, &LOCK_slave); + while(slave_running) + { + /* there is a small change that slave thread might miss the first + alarm. To protect againts it, resend the signal until it reacts + */ + + struct timespec abstime; +#ifdef HAVE_TIMESPEC_TS_SEC + abstime.ts_sec=time(NULL)+2; + abstime.ts_nsec=0; +#else + struct timeval tv; + gettimeofday(&tv,0); + abstime.tv_sec=tv.tv_sec+2; + abstime.tv_nsec=tv.tv_usec*1000; +#endif + pthread_cond_timedwait(&COND_slave_stopped, &LOCK_slave, &abstime); + if (slave_running) + thr_alarm_kill(slave_real_id); + } } else slave_errno = ER_SLAVE_NOT_RUNNING; |