diff options
Diffstat (limited to 'sql/handle_connections_win.cc')
-rw-r--r-- | sql/handle_connections_win.cc | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/sql/handle_connections_win.cc b/sql/handle_connections_win.cc index 50fd9090e0a..b61130dd6e9 100644 --- a/sql/handle_connections_win.cc +++ b/sql/handle_connections_win.cc @@ -377,7 +377,7 @@ struct Pipe_Listener : public Listener { PTP_CALLBACK_ENVIRON m_tp_env; Pipe_Listener(): - Listener(INVALID_HANDLE_VALUE, CreateEvent(0, FALSE, FALSE, 0)), + Listener(create_named_pipe(), CreateEvent(0, FALSE, FALSE, 0)), m_tp_env(get_threadpool_win_callback_environ()) { } @@ -412,7 +412,7 @@ struct Pipe_Listener : public Listener { sql_perror("Create named pipe failed"); sql_print_error("Aborting"); - exit(1); + unireg_abort(1); } first_instance= false; return pipe_handle; @@ -420,17 +420,14 @@ struct Pipe_Listener : public Listener static void create_pipe_connection(HANDLE pipe) { - CONNECT *connect; - if (!(connect= new CONNECT) || !(connect->vio= vio_new_win32pipe(pipe))) + if (auto connect= new CONNECT(pipe)) + create_new_thread(connect); + else { CloseHandle(pipe); - delete connect; statistic_increment(aborted_connects, &LOCK_status); statistic_increment(connection_errors_internal, &LOCK_status); - return; } - connect->host= my_localhost; - create_new_thread(connect); } /* Threadpool callback.*/ @@ -443,7 +440,6 @@ struct Pipe_Listener : public Listener void begin_accept() { - m_handle= create_named_pipe(); BOOL connected= ConnectNamedPipe(m_handle, &m_overlapped); if (connected) { @@ -488,11 +484,12 @@ struct Pipe_Listener : public Listener sql_print_warning("ConnectNamedPipe completed with %u", GetLastError()); #endif CloseHandle(m_handle); - m_handle= INVALID_HANDLE_VALUE; + m_handle= create_named_pipe(); begin_accept(); return; } HANDLE pipe= m_handle; + m_handle= create_named_pipe(); begin_accept(); // If threadpool is on, create connection in threadpool thread if (!m_tp_env || !TrySubmitThreadpoolCallback(tp_create_pipe_connection, pipe, m_tp_env)) @@ -537,13 +534,12 @@ 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; +void network_init_win() +{ Socket_Listener::init_winsock_extensions(); /* Listen for TCP connections on "extra-port" (no threadpool).*/ @@ -572,16 +568,22 @@ void handle_connections_win() sql_print_error("Either TCP connections or named pipe connections must be enabled."); unireg_abort(1); } +} + +void handle_connections_win() +{ + DBUG_ASSERT(hEventShutdown); + int n_waits; wait_events[SHUTDOWN_IDX]= hEventShutdown; - n_waits = 1; + n_waits= 1; - for (int i= 0; i < n_listeners; i++) + for (int i= 0; i < n_listeners; i++) { HANDLE wait_handle= all_listeners[i]->wait_handle(); - if(wait_handle) + if (wait_handle) { - DBUG_ASSERT((i == 0) || (all_listeners[i-1]->wait_handle() != 0)); + DBUG_ASSERT((i == 0) || (all_listeners[i - 1]->wait_handle() != 0)); wait_events[n_waits++]= wait_handle; } all_listeners[i]->begin_accept(); |