From 48ed7792a5e656ba707fbfad336bf1c730dc5a2d Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 26 Apr 2017 10:57:50 +0300 Subject: [PATCH] Arrange so that startup connections are handled by main Worker When the Worker mechanism has been initialized the current_worker_id of the calling thread is set to 0. That way, connections can be created after Worker::init() has been called, but before the workers have been started. Such connections will be handled by the worker that is running in the main thread. --- server/core/worker.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/core/worker.cc b/server/core/worker.cc index ff7cd61df..8b0275cd1 100644 --- a/server/core/worker.cc +++ b/server/core/worker.cc @@ -214,6 +214,16 @@ bool Worker::init() MXS_ERROR("Could not allocate an epoll instance."); } + if (this_unit.initialized) + { + // When the initialization has successfully been performed, we set the + // current_worker_id of this thread to 0. That way any connections that + // are made during service startup (after this function returns, but + // bofore the workes have been started) will be handled by the worker + // that will be running in the main thread. + this_thread.current_worker_id = 0; + } + return this_unit.initialized; }