From beba95a43a39711a11663024f7065375095e22e6 Mon Sep 17 00:00:00 2001 From: Jake Smith Date: Mon, 10 Jul 2023 17:40:43 +0100 Subject: [PATCH] HPCC-29923 Avoid CRowServer cancel if not running This avoids an inherent delay being introduced by the MP layer. CRowServer is used by Global Group, Global TopN and a refactoring form of IndexWrite (where is merges down to less parts). Signed-off-by: Jake Smith --- thorlcr/thorutil/thormisc.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/thorlcr/thorutil/thormisc.cpp b/thorlcr/thorutil/thormisc.cpp index 7d8c76fa284..d216db1aef7 100644 --- a/thorlcr/thorutil/thormisc.cpp +++ b/thorlcr/thorutil/thormisc.cpp @@ -1371,8 +1371,12 @@ class CRowServer : public CSimpleInterface, implements IThreaded, implements IRo #ifdef TRACE_GLOBAL_GROUP ActPrintLog(activity, "%s", __func__); #endif - running = false; - comm.cancel(RANK_ALL, mpTag); + bool wanted = true; + if (running.compare_exchange_strong(wanted, false)) + { + running = false; + comm.cancel(RANK_ALL, mpTag); + } } };