From 69b3879357c35cd21e4952cf109fee0e1ae8664a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 18 Jun 2019 11:00:58 +0300 Subject: [PATCH] MXS-2547: Don't post messages to stopped workers If a worker has been stopped, tasks must not be executed on it. To prevent this, the calling code should check whether the worker has been stopped. This does not prevent the case where a message is successfully posted to a worker but the worker is stopped before it processes it. --- server/core/worker.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/core/worker.cc b/server/core/worker.cc index 6d6990caa..b92ef49c4 100644 --- a/server/core/worker.cc +++ b/server/core/worker.cc @@ -718,12 +718,17 @@ size_t Worker::execute_concurrently(Task& task) bool Worker::post_message(uint32_t msg_id, intptr_t arg1, intptr_t arg2) { + // NOTE: No logging here, this function must be signal safe. + bool rval = false; ss_dassert(state() != Worker::STOPPED); - // NOTE: No logging here, this function must be signal safe. - MessageQueue::Message message(msg_id, arg1, arg2); + if (state() != Worker::STOPPED) + { + MessageQueue::Message message(msg_id, arg1, arg2); + rval = m_pQueue->post(message); + } - return m_pQueue->post(message); + return rval; } bool mxs_worker_post_message(MXS_WORKER* pWorker, uint32_t msg_id, intptr_t arg1, intptr_t arg2)