From d025f5123ecf5320745b50d2723bed4a36abeb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 4 Jun 2020 15:31:17 +0300 Subject: [PATCH] MXS-3023: Fix ID generator overflow The result must always be non-negative. --- server/core/routingworker.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/routingworker.cc b/server/core/routingworker.cc index bbc5b88cc..fcad1f07c 100644 --- a/server/core/routingworker.cc +++ b/server/core/routingworker.cc @@ -1064,7 +1064,7 @@ std::unique_ptr RoutingWorker::get_qc_stats_as_json(const char* zHost) // static RoutingWorker* RoutingWorker::pick_worker() { - static int id_generator = 0; + static uint32_t id_generator = 0; int id = this_unit.id_min_worker + (mxb::atomic::add(&id_generator, 1, mxb::atomic::RELAXED) % this_unit.nWorkers); return get(id);