changeset 743:9a7eedece65f

fix WADO-LOAD-xxx thread names
author Alain Mazy <am@orthanc.team>
date Fri, 13 Feb 2026 10:05:12 +0100
parents 743e4bf6a23d
children fce05c8b00fb
files Plugin/WadoRs.cpp
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/WadoRs.cpp	Tue Jan 27 17:00:34 2026 +0100
+++ b/Plugin/WadoRs.cpp	Fri Feb 13 10:05:12 2026 +0100
@@ -57,6 +57,10 @@
 static bool pluginCanUseExtendedFind_ = false;
 static bool isSystemReadOnly_ = false;
 
+static boost::mutex preloaderThreadsCounterMutex;
+static uint32_t preloaderThreadsCounter = 0;
+
+
 void SetPluginCanUseExtendedFind(bool enable)
 {
   pluginCanUseExtendedFind_ = enable;
@@ -515,8 +519,11 @@
 
   static void PreloaderWorkerThread(ThreadedInstanceLoader* that)
   {
-    static uint16_t threadCounter = 0;
-    Orthanc::Logging::SetCurrentThreadName(std::string("WADO-LOAD-") + boost::lexical_cast<std::string>(threadCounter++));
+    {
+      boost::mutex::scoped_lock lock(preloaderThreadsCounterMutex);
+      Orthanc::Logging::SetCurrentThreadName(std::string("WADO-LOAD-") + boost::lexical_cast<std::string>(preloaderThreadsCounter++));
+      preloaderThreadsCounter %= 1000000;
+    }
 
     LOG(INFO) << "Loader thread has started";