diff OrthancServer/ServerContext.cpp @ 1129:8dabdc0d3007

fix possible deadlock
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Sep 2014 15:47:53 +0200
parents bf67431a7383
children 382e162c074c
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp	Mon Sep 08 15:22:21 2014 +0200
+++ b/OrthancServer/ServerContext.cpp	Mon Sep 08 15:47:53 2014 +0200
@@ -460,14 +460,14 @@
 
   ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& that,
                                                     const std::string& instancePublicId) : 
-    that_(that)
+    that_(that),
+    lock_(that_.dicomCacheMutex_)
   {
 #if ENABLE_DICOM_CACHE == 0
     static std::auto_ptr<IDynamicObject> p;
     p.reset(provider_.Provide(instancePublicId));
     dicom_ = dynamic_cast<ParsedDicomFile*>(p.get());
 #else
-    that_.dicomCacheMutex_.lock();
     dicom_ = &dynamic_cast<ParsedDicomFile&>(that_.dicomCache_.Access(instancePublicId));
 #endif
   }
@@ -475,10 +475,6 @@
 
   ServerContext::DicomCacheLocker::~DicomCacheLocker()
   {
-#if ENABLE_DICOM_CACHE == 0
-#else
-    that_.dicomCacheMutex_.unlock();
-#endif
   }