Mercurial > hg > orthanc
changeset 6950:66648e78eccb streaming
in debug, make sure we do not reuse twice the same thread name
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Tue, 16 Jun 2026 09:31:10 +0200 |
| parents | 82cba5fc24a3 |
| children | 07201dc3b5b8 |
| files | OrthancFramework/Sources/Logging.cpp |
| diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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__)
