Commit 602d3daf authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-23279 postfix - delay accepting connections until server startup is finished.

parent 6a7e646d
...@@ -319,7 +319,7 @@ struct Pipe_Listener : public Listener ...@@ -319,7 +319,7 @@ struct Pipe_Listener : public Listener
{ {
PTP_CALLBACK_ENVIRON m_tp_env; PTP_CALLBACK_ENVIRON m_tp_env;
Pipe_Listener(): 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()) m_tp_env(get_threadpool_win_callback_environ())
{ {
} }
...@@ -388,7 +388,6 @@ struct Pipe_Listener : public Listener ...@@ -388,7 +388,6 @@ struct Pipe_Listener : public Listener
void begin_accept() void begin_accept()
{ {
m_handle= create_named_pipe();
BOOL connected= ConnectNamedPipe(m_handle, &m_overlapped); BOOL connected= ConnectNamedPipe(m_handle, &m_overlapped);
if (connected) if (connected)
{ {
...@@ -433,11 +432,12 @@ struct Pipe_Listener : public Listener ...@@ -433,11 +432,12 @@ struct Pipe_Listener : public Listener
sql_print_warning("ConnectNamedPipe completed with %u", GetLastError()); sql_print_warning("ConnectNamedPipe completed with %u", GetLastError());
#endif #endif
CloseHandle(m_handle); CloseHandle(m_handle);
m_handle= INVALID_HANDLE_VALUE; m_handle= create_named_pipe();
begin_accept(); begin_accept();
return; return;
} }
HANDLE pipe= m_handle; HANDLE pipe= m_handle;
m_handle= create_named_pipe();
begin_accept(); begin_accept();
// If threadpool is on, create connection in threadpool thread // If threadpool is on, create connection in threadpool thread
if (!m_tp_env || !TrySubmitThreadpoolCallback(tp_create_pipe_connection, pipe, m_tp_env)) if (!m_tp_env || !TrySubmitThreadpoolCallback(tp_create_pipe_connection, pipe, m_tp_env))
...@@ -485,7 +485,6 @@ struct Pipe_Listener : public Listener ...@@ -485,7 +485,6 @@ struct Pipe_Listener : public Listener
static Listener *all_listeners[MAX_WAIT_HANDLES]; static Listener *all_listeners[MAX_WAIT_HANDLES];
static HANDLE wait_events[MAX_WAIT_HANDLES]; static HANDLE wait_events[MAX_WAIT_HANDLES];
static int n_listeners; static int n_listeners;
static int n_waits;
void network_init_win() void network_init_win()
{ {
...@@ -517,27 +516,27 @@ void network_init_win() ...@@ -517,27 +516,27 @@ void network_init_win()
sql_print_error("Either TCP connections or named pipe connections must be enabled."); sql_print_error("Either TCP connections or named pipe connections must be enabled.");
unireg_abort(1); unireg_abort(1);
} }
}
void handle_connections_win()
{
DBUG_ASSERT(hEventShutdown);
int n_waits;
n_waits = 1; wait_events[SHUTDOWN_IDX]= hEventShutdown;
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(); 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; wait_events[n_waits++]= wait_handle;
} }
all_listeners[i]->begin_accept(); all_listeners[i]->begin_accept();
} }
}
void handle_connections_win()
{
DBUG_ASSERT(hEventShutdown);
DBUG_ASSERT(n_waits);
wait_events[SHUTDOWN_IDX]= hEventShutdown;
for (;;) for (;;)
{ {
DWORD idx = WaitForMultipleObjects(n_waits ,wait_events, FALSE, INFINITE); DWORD idx = WaitForMultipleObjects(n_waits ,wait_events, FALSE, INFINITE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment