# HG changeset patch # User Alain Mazy # Date 1764673408 -3600 # Node ID e0979326ac5374ba09dac1c19da9c254e259a3a1 # Parent 5541a6b13500d42f8a09529cbb7722fe845aedd9# Parent 81f2cea4ab5f65f0e6c3e045b82d513364248859 merge diff -r 81f2cea4ab5f -r e0979326ac53 OrthancFramework/Sources/Logging.cpp --- a/OrthancFramework/Sources/Logging.cpp Tue Dec 02 12:00:10 2025 +0100 +++ b/OrthancFramework/Sources/Logging.cpp Tue Dec 02 12:03:28 2025 +0100 @@ -501,6 +501,7 @@ _OrthancPluginService_LogInfo = 1, _OrthancPluginService_LogWarning = 2, _OrthancPluginService_LogError = 3, + _OrthancPluginService_SetCurrentThreadName = 44, _OrthancPluginService_LogMessage = 45, _OrthancPluginService_INTERNAL = 0x7fffffff } _OrthancPluginService; @@ -671,15 +672,22 @@ void SetCurrentThreadName(const std::string& name) { - boost::recursive_mutex::scoped_lock lock(threadNamesMutex_); - SetCurrentThreadNameInternal(boost::this_thread::get_id(), name); + if (pluginContext_ == NULL) + { + boost::recursive_mutex::scoped_lock lock(threadNamesMutex_); + SetCurrentThreadNameInternal(boost::this_thread::get_id(), name); + } + else + { + pluginContext_->InvokeService(pluginContext_, _OrthancPluginService_SetCurrentThreadName, name.c_str()); + } } bool HasCurrentThreadName() { boost::thread::id threadId = boost::this_thread::get_id(); - boost::mutex::scoped_lock lock(loggingStreamsMutex_); + boost::recursive_mutex::scoped_lock lock(threadNamesMutex_); return threadNames_.find(threadId) != threadNames_.end(); } diff -r 81f2cea4ab5f -r e0979326ac53 OrthancServer/Sources/ServerJobs/ArchiveJob.cpp --- a/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Tue Dec 02 12:00:10 2025 +0100 +++ b/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Tue Dec 02 12:03:28 2025 +0100 @@ -56,6 +56,8 @@ static const char* const KEY_ARCHIVE_SIZE = "ArchiveSize"; static const char* const KEY_TRANSCODE = "Transcode"; +static boost::mutex loaderThreadsCounterMutex; +static uint32_t loaderThreadsCounter = 0; namespace Orthanc { @@ -251,8 +253,11 @@ static void PreloaderWorkerThread(ThreadedInstanceLoader* that) { - static uint16_t threadCounter = 0; - Logging::SetCurrentThreadName(std::string("ARCH-LOAD-") + boost::lexical_cast(threadCounter++)); + { + boost::mutex::scoped_lock lock(loaderThreadsCounterMutex); + Logging::SetCurrentThreadName(std::string("ARCH-LOAD-") + boost::lexical_cast(loaderThreadsCounter++)); + loaderThreadsCounter %= 1000000; + } LOG(INFO) << "Loader thread has started"; diff -r 81f2cea4ab5f -r e0979326ac53 OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp --- a/OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp Tue Dec 02 12:00:10 2025 +0100 +++ b/OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp Tue Dec 02 12:03:28 2025 +0100 @@ -31,6 +31,10 @@ #include #include +static boost::mutex instanceWorkerThreadsCounterMutex; +static uint32_t instanceWorkerThreadsCounter = 0; + + namespace Orthanc { static const char* EXIT_WORKER_MESSAGE = "exit"; @@ -244,9 +248,11 @@ void ThreadedSetOfInstancesJob::InstanceWorkerThread(ThreadedSetOfInstancesJob* that) { - static uint16_t threadCounter = 0; - Logging::SetCurrentThreadName(std::string("JOB-INS-WORK-") + boost::lexical_cast(threadCounter++)); - threadCounter %= 1000; + { + boost::mutex::scoped_lock lock(instanceWorkerThreadsCounterMutex); + Logging::SetCurrentThreadName(std::string("JOB-INS-WORK-") + boost::lexical_cast(instanceWorkerThreadsCounter++)); + instanceWorkerThreadsCounter %= 1000; + } while (true) {