List:Commits« Previous MessageNext Message »
From:Ignacio Galarza Date:February 7 2008 11:15pm
Subject:bk commit into 5.0 tree (iggy:1.2573) BUG#26243
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of iggy.  When iggy does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-02-07 17:15:12-05:00, iggy@alf.(none) +1 -0
  Bug#26243 mysql command line crash after control-c
  - Avoid memory cleanup race on Windows for CTRL-C.

  client/mysql.cc@stripped, 2008-02-07 17:15:10-05:00, iggy@alf.(none) +14 -2
    Bug#26243 mysql command line crash after control-c
    - signal handler thread spawned by Windows to deal with the control-c 
    and main thread race to call mysql_end().  Remove duplication of
    effort.

diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc	2008-01-30 16:51:37 -05:00
+++ b/client/mysql.cc	2008-02-07 17:15:10 -05:00
@@ -1210,6 +1210,11 @@ int main(int argc,char *argv[])
 #endif
 }
 
+/*
+ When SIGINT is raised on Windows, the operating system creates a new thread to
+ handle the interrupt.  The main thread continues running and races the handler 
+ to call mysql_end().  No racing allowed..
+*/
 sig_handler mysql_sigint(int sig)
 {
   char kill_buffer[40];
@@ -1219,17 +1224,24 @@ sig_handler mysql_sigint(int sig)
 
   /* terminate if no query being executed, or we already tried interrupting */
   if (!executing_query || interrupted_query++)
-    mysql_end(sig);
+    goto err;
 
   kill_mysql= mysql_init(kill_mysql);
   if (!mysql_real_connect(kill_mysql,current_host, current_user, opt_password,
                           "", opt_mysql_port, opt_mysql_unix_port,0))
-    mysql_end(sig);
+    goto err;
   /* kill_buffer is always big enough because max length of %lu is 15 */
   sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
   mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
   mysql_close(kill_mysql);
   tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
+
+err:
+#ifndef _WIN32
+    mysql_end(sig);
+#else
+    return;
+#endif
 }
 
 sig_handler mysql_end(int sig)
Thread
bk commit into 5.0 tree (iggy:1.2573) BUG#26243Ignacio Galarza7 Feb