diff OrthancServer/DicomProtocol/DicomServer.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 6e7e5ed91c2d
children 9de4fa64e29c
line wrap: on
line diff
--- a/OrthancServer/DicomProtocol/DicomServer.cpp	Thu Jul 02 11:35:41 2015 +0200
+++ b/OrthancServer/DicomProtocol/DicomServer.cpp	Thu Jul 02 12:26:44 2015 +0200
@@ -223,7 +223,11 @@
 
   DicomServer::~DicomServer()
   {
-    Stop();
+    if (continue_)
+    {
+      LOG(ERROR) << "INTERNAL ERROR: DicomServer::Stop() should be invoked manually to avoid mess in the destruction order!";
+      Stop();
+    }
   }
 
   void DicomServer::SetPortNumber(uint16_t port)
@@ -409,16 +413,21 @@
     }
   }
 
+
   void DicomServer::Stop()
   {
-    continue_ = false;
+    if (continue_)
+    {
+      continue_ = false;
 
-    if (pimpl_->thread_.joinable())
-    {
-      pimpl_->thread_.join();
+      if (pimpl_->thread_.joinable())
+      {
+        pimpl_->thread_.join();
+      }
     }
   }
 
+
   bool DicomServer::IsMyAETitle(const std::string& aet) const
   {
     if (!HasCalledApplicationEntityTitleCheck())