summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorunknown <iggy@amd64.(none)>2008-03-28 14:02:27 -0400
committerunknown <iggy@amd64.(none)>2008-03-28 14:02:27 -0400
commita9089cf460c7d7be3d8b843c948f0c707822878e (patch)
treebd2b7d6f189d12c7958ade6c6684233a9fae3607 /client
parentfd1616311d7fa2b64a3911ae8e79cd05fa2c8782 (diff)
downloadmariadb-git-a9089cf460c7d7be3d8b843c948f0c707822878e.tar.gz
Bug#26243 mysql command line crash after control-c
- Backported the 5.1 DBUG to 5.0. - Avoid memory cleanup race on Windows client for CTRL-C client/mysql.cc: Bug#26243 mysql command line crash after control-c - On Windows, the sigint handler shouldn't call mysql_end because the main thread will do so automatically. - Remove unnecessary signal call from the sigint handler. - Call my_end with proper value. dbug/dbug.c: Bug#26243 mysql command line crash after control-c - Backported the 5.1 DBUG library. The old version uses a non-thread safe global variable 'static struct state *stack'. dbug/factorial.c: Bug#26243 mysql command line crash after control-c - Backported the 5.1 DBUG library. The old version uses a non-thread safe global variable 'static struct state *stack'. dbug/user.r: Bug#26243 mysql command line crash after control-c - Backported the 5.1 DBUG library. The old version uses a non-thread safe global variable 'static struct state *stack'. include/my_dbug.h: Bug#26243 mysql command line crash after control-c - Backported the 5.1 DBUG library. The old version uses a non-thread safe global variable 'static struct state *stack'. libmysql/libmysql.c: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. myisam/mi_open.c: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/ha_federated.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/ha_innodb.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/ha_myisammrg.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/item_cmpfunc.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/mysqld.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/net_serv.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/opt_range.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/set_var.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/slave.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/sql_cache.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. sql/sql_select.cc: Bug#26243 mysql command line crash after control-c - Update for new DBUG library. tests/mysql_client_test.c: Bug#26243 mysql command line crash after control-c - Update for new DBUG library.
Diffstat (limited to 'client')
-rw-r--r--client/mysql.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 483b1829ec0..a4706a1c580 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1216,21 +1216,35 @@ sig_handler mysql_sigint(int sig)
char kill_buffer[40];
MYSQL *kill_mysql= NULL;
- signal(SIGINT, mysql_sigint);
-
/* 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");
+
+ return;
+
+err:
+#ifdef _WIN32
+ /*
+ When SIGINT is raised on Windows, the OS creates a new thread to handle the
+ interrupt. Once that thread completes, the main thread continues running
+ only to find that it's resources have already been free'd when the sigint
+ handler called mysql_end().
+ */
+ mysql_thread_end();
+ return;
+#else
+ mysql_end(sig);
+#endif
}
sig_handler mysql_end(int sig)
@@ -1271,7 +1285,7 @@ sig_handler mysql_end(int sig)
my_free(current_prompt,MYF(MY_ALLOW_ZERO_PTR));
mysql_server_end();
free_defaults(defaults_argv);
- my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
+ my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
exit(status.exit_status);
}