# HG changeset patch
# User Sebastien Jodogne <s.jodogne@gmail.com>
# Date 1368267560 -7200
# Node ID 16b52fb8d0342eaebf64cc5a24ccad14c843223e
# Parent  f746592d8301be7c1390444342b47301526278eb
fix by cyril paulus

diff -r f746592d8301 -r 16b52fb8d034 Core/MultiThreading/BagOfRunnablesBySteps.cpp
--- a/Core/MultiThreading/BagOfRunnablesBySteps.cpp	Wed May 08 15:16:13 2013 +0200
+++ b/Core/MultiThreading/BagOfRunnablesBySteps.cpp	Sat May 11 12:19:20 2013 +0200
@@ -102,7 +102,11 @@
         assert(t.get() != NULL);
         assert(bag->pimpl_->activeThreads_.find(r.get()) == bag->pimpl_->activeThreads_.end());
 
-        t->join();
+        if (t->joinable())
+        {
+          t->join();
+        }
+
         bag->pimpl_->oneThreadIsJoined_.notify_one();
       }
 
@@ -128,7 +132,11 @@
     // Stop the finish listener
     pimpl_->stopFinishListener_ = true;
     pimpl_->oneThreadIsStopped_.notify_one();  // Awakens the listener
-    pimpl_->finishListener_->join();
+
+    if (pimpl_->finishListener_->joinable())
+    {
+      pimpl_->finishListener_->join();
+    }
   }
 
 
diff -r f746592d8301 -r 16b52fb8d034 OrthancServer/DicomProtocol/DicomServer.cpp
--- a/OrthancServer/DicomProtocol/DicomServer.cpp	Wed May 08 15:16:13 2013 +0200
+++ b/OrthancServer/DicomProtocol/DicomServer.cpp	Sat May 11 12:19:20 2013 +0200
@@ -385,7 +385,11 @@
   void DicomServer::Stop()
   {
     continue_ = false;
-    pimpl_->thread_.join();
+
+    if (pimpl_->thread_.joinable())
+    {
+      pimpl_->thread_.join();
+    }
 
     bagOfDispatchers_.StopAll();
   }
diff -r f746592d8301 -r 16b52fb8d034 OrthancServer/ServerIndex.cpp
--- a/OrthancServer/ServerIndex.cpp	Wed May 08 15:16:13 2013 +0200
+++ b/OrthancServer/ServerIndex.cpp	Sat May 11 12:19:20 2013 +0200
@@ -291,8 +291,6 @@
   ServerIndex::~ServerIndex()
   {
     LOG(INFO) << "Stopping the database flushing thread";
-    /*flushThread_.terminate();
-      flushThread_.join();*/
   }