From de0541f76b7534425f379fde7bc9237cde97ce87 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 22 May 2018 16:49:16 +0300 Subject: [PATCH] MXS-1875 Use RoutingWorker and not Worker DCBs will only be used in conjunction with RoutingWorkers and hence RoutingWorker and not just Worker must be used when looking for the current worker and worker id. The reason is that RoutingWorker cheats; the current worker id is set to 0 at initialization time, which indicates that a worker would be running although it isn't. The reason is that as listeners are created before any worker has been started, that arrangement ensures that listening DCBs are book-kept in the worker running in the main thread. Now, that is a kludge. It ought to be changed so that a, say, MainRoutingWorker class is introduced that in its run function initializes MaxScale and then continues running as any regular RoutingWorker. In due time. --- server/core/dcb.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 78d88444e..a9f7ac094 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -2814,7 +2814,7 @@ static void dcb_add_to_list(DCB *dcb) * is not in the list. Stopped listeners are not removed from the list. */ - ss_dassert(dcb->poll.thread.id == Worker::get_current_id()); + ss_dassert(dcb->poll.thread.id == RoutingWorker::get_current_id()); if (this_unit.all_dcbs[dcb->poll.thread.id] == NULL) { @@ -3466,7 +3466,7 @@ static bool dcb_add_to_worker(int worker_id, DCB* dcb, uint32_t events) { // If this takes place on the main thread (all listening DCBs are // stored on the main thread), - if (dcb->poll.thread.id == Worker::get_current_id()) + if (dcb->poll.thread.id == RoutingWorker::get_current_id()) { // we'll add it immediately to the list, dcb_add_to_list(dcb); @@ -3475,7 +3475,7 @@ static bool dcb_add_to_worker(int worker_id, DCB* dcb, uint32_t events) { // otherwise we must move the adding to the main thread. // TODO: Separate listening and other DCBs, as this is a mess. - Worker* worker = Worker::get(dcb->poll.thread.id); + Worker* worker = RoutingWorker::get(dcb->poll.thread.id); ss_dassert(worker); intptr_t arg1 = (intptr_t)dcb_add_to_list_cb; @@ -3494,7 +3494,7 @@ static bool dcb_add_to_worker(int worker_id, DCB* dcb, uint32_t events) { ss_dassert(worker_id == dcb->poll.thread.id); - if (worker_id == Worker::get_current_id()) + if (worker_id == RoutingWorker::get_current_id()) { // If the DCB should end up on the current thread, we can both add it // to the epoll-instance and to the DCB book-keeping immediately. @@ -3514,7 +3514,7 @@ static bool dcb_add_to_worker(int worker_id, DCB* dcb, uint32_t events) if (task) { - Worker* worker = Worker::get(dcb->poll.thread.id); + Worker* worker = RoutingWorker::get(dcb->poll.thread.id); ss_dassert(worker); if (worker->post(std::auto_ptr(task), mxs::Worker::EXECUTE_QUEUED))