summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@station.>2007-11-15 15:35:35 +0300
committerunknown <anozdrin/alik@station.>2007-11-15 15:35:35 +0300
commit41bd3c8749b90dabae0801c2b8dd37cd0edc47d6 (patch)
treed8b742889e9b1796277e17a4ef5fdf79756809dc /sql/sql_class.cc
parentb9d862f62051d51081cb092fc211fdd29105614f (diff)
downloadmariadb-git-41bd3c8749b90dabae0801c2b8dd37cd0edc47d6.tar.gz
A patch for BUG#19723: kill of active connection yields
different error code depending on platform. On Mac OS X, KILL statement issued to kill the current connection would return a different error code and message than on other platforms ('MySQL server has gone away' instead of 'Shutdown in progress'). The reason for this difference was that on Mac OS X we have macro SIGNAL_WITH_VIO_CLOSE defined. This macro forces KILL implementation to close the communication socket of the thread that is being killed. SIGNAL_WITH_VIO_CLOSE macro is defined on platforms where just sending a signal is not a reliable mechanism to interrupt the thread from sleeping on a blocking system call. In a nutshell, closing the socket is a hack to work around an operating system bug and awake the blocked thread no matter what. However, if the thread that is being killed is the same thread that issued KILL statement, closing the socket leads to a prematurely lost connection. At the same time it is not necessary to close the socket in this case, since the thread in question is not inside a blocking system call. The fix, therefore, is to not close the socket if the thread that is being killed is the same that issued KILL statement, even with defined SIGNAL_WITH_VIO_CLOSE. mysql-test/r/kill.result: Update result file. mysql-test/t/kill.test: Added a test case for BUG#19723: kill of active connection yields different error code depending on platform. sql/sql_class.cc: Call close_active_vio() only if we're killing another thread.
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index a904023cbff..368ed897a4d 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -818,7 +818,20 @@ void THD::awake(THD::killed_state state_to_set)
if (!slave_thread)
thread_scheduler.post_kill_notification(this);
#ifdef SIGNAL_WITH_VIO_CLOSE
- close_active_vio();
+ if (this != current_thd)
+ {
+ /*
+ In addition to a signal, let's close the socket of the thread that
+ is being killed. This is to make sure it does not block if the
+ signal is lost. This needs to be done only on platforms where
+ signals are not a reliable interruption mechanism.
+
+ If we're killing ourselves, we know that we're not blocked, so this
+ hack is not used.
+ */
+
+ close_active_vio();
+ }
#endif
}
if (mysys_var)