diff --git a/thorlcr/thorutil/thormisc.cpp b/thorlcr/thorutil/thormisc.cpp index 24faa992900..4d774eac2ea 100644 --- a/thorlcr/thorutil/thormisc.cpp +++ b/thorlcr/thorutil/thormisc.cpp @@ -1364,8 +1364,9 @@ 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)) + comm.cancel(RANK_ALL, mpTag); } };