From 728c780187128cb6192963589f3adee0b3df8e11 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 26 Apr 2017 13:17:23 +0300 Subject: [PATCH] Expose current worker id to c-files --- include/maxscale/worker.h | 9 +++++++++ server/core/worker.cc | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/maxscale/worker.h b/include/maxscale/worker.h index 06a753fb3..ef66c57fc 100644 --- a/include/maxscale/worker.h +++ b/include/maxscale/worker.h @@ -69,6 +69,15 @@ MXS_WORKER* mxs_worker_get(int worker_id); */ int mxs_worker_id(MXS_WORKER* pWorker); +/** + * Return the id of the worker. + * + * @return The id of the worker. + * + * @attention If there is no current worker, then -1 will be returned. + */ +int mxs_worker_get_current_id(); + /** * Post a message to a worker. * diff --git a/server/core/worker.cc b/server/core/worker.cc index 8b0275cd1..4b3e5ac1f 100644 --- a/server/core/worker.cc +++ b/server/core/worker.cc @@ -512,6 +512,11 @@ MXS_WORKER* mxs_worker_get(int worker_id) return Worker::get(worker_id); } +int mxs_worker_get_current_id() +{ + return Worker::get_current_id(); +} + Worker* Worker::get_current() { Worker* pWorker = NULL;