From d50ae1fb8a9e8e565ec744ae6c286dd27f9b1ff4 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 7 Jan 2019 16:23:38 +0200 Subject: [PATCH] MXS-2218 Treat all routing workers the same way All routing workers are now started an stopped the same way. --- include/maxscale/routingworker.hh | 11 +++++----- server/core/gateway.cc | 7 ++----- server/core/routingworker.cc | 34 ++++++++++++------------------- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/include/maxscale/routingworker.hh b/include/maxscale/routingworker.hh index 400519f70..965828737 100644 --- a/include/maxscale/routingworker.hh +++ b/include/maxscale/routingworker.hh @@ -287,17 +287,16 @@ public: static int get_current_id(); /** - * Starts all routing workers but the main worker (the one running in - * the main thread). + * Starts all routing workers. * - * @return True, if all secondary workers could be started. + * @return True, if all workers could be started. */ - static bool start_threaded_workers(); + static bool start_workers(); /** - * Waits for all threaded workers. + * Waits for all routing workers. */ - static void join_threaded_workers(); + static void join_workers(); /** * Deprecated diff --git a/server/core/gateway.cc b/server/core/gateway.cc index d21cadba8..e40853cfa 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -2231,7 +2231,7 @@ int main(int argc, char** argv) /*< * Start the routing workers running in their own thread. */ - if (!RoutingWorker::start_threaded_workers()) + if (!RoutingWorker::start_workers()) { const char* logerr = "Failed to start routing workers."; print_log_n_stderr(true, true, logerr, logerr, 0); @@ -2279,8 +2279,6 @@ int main(int argc, char** argv) goto return_main; } - worker->start(); - main_worker->run(); /** Stop administrative interface */ @@ -2297,11 +2295,10 @@ int main(int argc, char** argv) */ hkfinish(); - worker->join(); /*< * Wait for worker threads to exit. */ - RoutingWorker::join_threaded_workers(); + RoutingWorker::join_workers(); MXS_NOTICE("All workers have shut down."); diff --git a/server/core/routingworker.cc b/server/core/routingworker.cc index c317cc5b9..accbe76e2 100644 --- a/server/core/routingworker.cc +++ b/server/core/routingworker.cc @@ -476,26 +476,21 @@ int RoutingWorker::get_current_id() } // static -bool RoutingWorker::start_threaded_workers() +bool RoutingWorker::start_workers() { bool rv = true; for (int i = this_unit.id_min_worker; i <= this_unit.id_max_worker; ++i) { - // The main RoutingWorker will run in the main thread, so - // we exclude that. - if (i != this_unit.id_main_worker) - { - RoutingWorker* pWorker = this_unit.ppWorkers[i]; - mxb_assert(pWorker); + RoutingWorker* pWorker = this_unit.ppWorkers[i]; + mxb_assert(pWorker); - if (!pWorker->start()) - { - MXS_ALERT("Could not start routing worker %d of %d.", i, config_threadcount()); - rv = false; - // At startup, so we don't even try to clean up. - break; - } + if (!pWorker->start()) + { + MXS_ALERT("Could not start routing worker %d of %d.", i, config_threadcount()); + rv = false; + // At startup, so we don't even try to clean up. + break; } } @@ -503,17 +498,14 @@ bool RoutingWorker::start_threaded_workers() } // static -void RoutingWorker::join_threaded_workers() +void RoutingWorker::join_workers() { for (int i = this_unit.id_min_worker; i <= this_unit.id_max_worker; i++) { - if (i != this_unit.id_main_worker) - { - RoutingWorker* pWorker = this_unit.ppWorkers[i]; - mxb_assert(pWorker); + RoutingWorker* pWorker = this_unit.ppWorkers[i]; + mxb_assert(pWorker); - pWorker->join(); - } + pWorker->join(); } }