Mercurial > hg > orthanc
diff OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp @ 1453:c0bdc47165ef
code to warn about possible threading problems
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 Jul 2015 12:26:44 +0200 |
parents | d710ea64f0fd |
children | f967bdf8534e |
line wrap: on
line diff
--- a/OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp Thu Jul 02 11:35:41 2015 +0200 +++ b/OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp Thu Jul 02 12:26:44 2015 +0200 @@ -131,9 +131,11 @@ ReusableDicomUserConnection::~ReusableDicomUserConnection() { - continue_ = false; - closeThread_.join(); - Close(); + if (continue_) + { + LOG(ERROR) << "INTERNAL ERROR: ReusableDicomUserConnection::Finalize() should be invoked manually to avoid mess in the destruction order!"; + Finalize(); + } } void ReusableDicomUserConnection::SetMillisecondsBeforeClose(uint64_t ms) @@ -166,5 +168,21 @@ lastUse_ = Now(); mutex_.unlock(); } + + + void ReusableDicomUserConnection::Finalize() + { + if (continue_) + { + continue_ = false; + + if (closeThread_.joinable()) + { + closeThread_.join(); + } + + Close(); + } + } }