# HG changeset patch # User Alain Mazy # Date 1764673339 -3600 # Node ID ef77a536195b64ac7738ef22126d7e24e56b4160 # Parent ebf563bfe42d3617d6529b98ee5fee1856bfbbb5 fix SetCurrentThreadName from plugins diff -r ebf563bfe42d -r ef77a536195b OrthancFramework/Sources/Logging.cpp --- a/OrthancFramework/Sources/Logging.cpp Tue Dec 02 10:09:49 2025 +0100 +++ b/OrthancFramework/Sources/Logging.cpp Tue Dec 02 12:02:19 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(); }