diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2020-08-10 17:33:48 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2020-08-10 17:33:48 +0000 |
commit | 4ea915e28c3fc8abd164977408f8a69b61e4a997 (patch) | |
tree | e31a0ea415c4d2a12769f99490686f791f6bba79 | |
parent | 5611df6774a7e60f2fc84350b88b60753628466e (diff) | |
download | mariadb-git-4ea915e28c3fc8abd164977408f8a69b61e4a997.tar.gz |
MDEV-23279 main.named_pipe test timeouts if called twice in a row
The test timeouts, because mtr is waiting for pid file.
The pid file is not there, because expected to fail mysqld startup
(duplicate named pipe name), this startup removed pid file of the running
mysqld instance.
To fix, split handle_connections_win() into the initialization part,
and accept/handle part, like it is done elsewhere.
The initialization part runs before pid file handling, and aborts on errors
, thus avoiding pid file overwrites.
-rw-r--r-- | mysql-test/main/named_pipe.test | 1 | ||||
-rw-r--r-- | sql/handle_connections_win.cc | 20 | ||||
-rw-r--r-- | sql/handle_connections_win.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 5 |
4 files changed, 20 insertions, 7 deletions
diff --git a/mysql-test/main/named_pipe.test b/mysql-test/main/named_pipe.test index 8e0136d06a9..3f01b415fc5 100644 --- a/mysql-test/main/named_pipe.test +++ b/mysql-test/main/named_pipe.test @@ -27,3 +27,4 @@ let $MYSQLD_DATADIR= `select @@datadir`; let SEARCH_FILE=$MYSQLD_DATADIR/second-mysqld.err; let SEARCH_PATTERN=\[ERROR\] Create named pipe failed; source include/search_pattern_in_file.inc; +remove_file $SEARCH_FILE; diff --git a/sql/handle_connections_win.cc b/sql/handle_connections_win.cc index 44ad8ddc865..8ac6daa4e9f 100644 --- a/sql/handle_connections_win.cc +++ b/sql/handle_connections_win.cc @@ -482,13 +482,13 @@ struct Pipe_Listener : public Listener #define SHUTDOWN_IDX 0 #define LISTENER_START_IDX 1 -void handle_connections_win() -{ - Listener* all_listeners[MAX_WAIT_HANDLES]= {}; - HANDLE wait_events[MAX_WAIT_HANDLES]= {}; - int n_listeners= 0; - int n_waits= 0; +static Listener *all_listeners[MAX_WAIT_HANDLES]; +static HANDLE wait_events[MAX_WAIT_HANDLES]; +static int n_listeners; +static int n_waits; +void network_init_win() +{ Socket_Listener::init_winsock_extensions(); /* Listen for TCP connections on "extra-port" (no threadpool).*/ @@ -518,7 +518,6 @@ void handle_connections_win() unireg_abort(1); } - wait_events[SHUTDOWN_IDX]= hEventShutdown; n_waits = 1; for (int i= 0; i < n_listeners; i++) @@ -531,7 +530,14 @@ void handle_connections_win() } all_listeners[i]->begin_accept(); } +} +void handle_connections_win() +{ + DBUG_ASSERT(hEventShutdown); + DBUG_ASSERT(n_waits); + + wait_events[SHUTDOWN_IDX]= hEventShutdown; for (;;) { DWORD idx = WaitForMultipleObjects(n_waits ,wait_events, FALSE, INFINITE); diff --git a/sql/handle_connections_win.h b/sql/handle_connections_win.h index a81f4346fb2..bf66c081473 100644 --- a/sql/handle_connections_win.h +++ b/sql/handle_connections_win.h @@ -18,3 +18,4 @@ Creates new (THD) connections.. */ extern void handle_connections_win(); +extern void network_init_win(); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ec641801300..1fadc7ebaac 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2526,6 +2526,11 @@ static void network_init(void) #endif } #endif + +#ifdef _WIN32 + network_init_win(); +#endif + DBUG_PRINT("info",("server started")); DBUG_VOID_RETURN; } |