# HG changeset patch # User Sebastien Jodogne # Date 1410184073 -7200 # Node ID 8dabdc0d300738de8e10f2df8ceb6ddbb61d3383 # Parent 514492f61eadd9a591949dc1419fbd3aa2214f49 fix possible deadlock diff -r 514492f61ead -r 8dabdc0d3007 OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Sep 08 15:22:21 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Sep 08 15:47:53 2014 +0200 @@ -262,6 +262,7 @@ continue; } + ParsedDicomFile& original = locker->GetDicom(); DicomInstanceHasher originalHasher = original.GetHasher(); diff -r 514492f61ead -r 8dabdc0d3007 OrthancServer/ServerContext.cpp --- 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 p; p.reset(provider_.Provide(instancePublicId)); dicom_ = dynamic_cast(p.get()); #else - that_.dicomCacheMutex_.lock(); dicom_ = &dynamic_cast(that_.dicomCache_.Access(instancePublicId)); #endif } @@ -475,10 +475,6 @@ ServerContext::DicomCacheLocker::~DicomCacheLocker() { -#if ENABLE_DICOM_CACHE == 0 -#else - that_.dicomCacheMutex_.unlock(); -#endif } diff -r 514492f61ead -r 8dabdc0d3007 OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Mon Sep 08 15:22:21 2014 +0200 +++ b/OrthancServer/ServerContext.h Mon Sep 08 15:47:53 2014 +0200 @@ -97,6 +97,7 @@ private: ServerContext& that_; ParsedDicomFile *dicom_; + boost::mutex::scoped_lock lock_; public: DicomCacheLocker(ServerContext& that,