# HG changeset patch # User Alain Mazy # Date 1781595070 -7200 # Node ID 66648e78eccb88a96142bdd909d4c70108b2ac97 # Parent 82cba5fc24a36fd5b0388fccfa4b6419119efef3 in debug, make sure we do not reuse twice the same thread name diff -r 82cba5fc24a3 -r 66648e78eccb OrthancFramework/Sources/Logging.cpp --- a/OrthancFramework/Sources/Logging.cpp Sat Jun 13 20:12:42 2026 +0200 +++ b/OrthancFramework/Sources/Logging.cpp Tue Jun 16 09:31:10 2026 +0200 @@ -732,6 +732,21 @@ throw OrthancException(ErrorCode_InternalError, std::string("Thread name can not exceed 16 characters: ") + name); } +#if !defined(NDEBUG) + if (threadNames_.find(id) != threadNames_.end()) + { + throw OrthancException(ErrorCode_InternalError, std::string("This thread already has a name or another thread is re-using the same threadId and you have not called 'ClearCurrentThreadName()': ") + name); + } + + for (ThreadNamesMap::const_iterator it = threadNames_.begin(); it != threadNames_.end(); ++it) + { + if (it->second == name) + { + throw OrthancException(ErrorCode_InternalError, std::string("Another thread already uses this thread name: ") + name); + } + } +#endif + threadNames_[id] = name; #if defined(__linux__) && !defined(NDEBUG) && !defined(__LSB_VERSION__)