Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1128:514492f61ead | 1129:8dabdc0d3007 |
---|---|
458 } | 458 } |
459 | 459 |
460 | 460 |
461 ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& that, | 461 ServerContext::DicomCacheLocker::DicomCacheLocker(ServerContext& that, |
462 const std::string& instancePublicId) : | 462 const std::string& instancePublicId) : |
463 that_(that) | 463 that_(that), |
464 lock_(that_.dicomCacheMutex_) | |
464 { | 465 { |
465 #if ENABLE_DICOM_CACHE == 0 | 466 #if ENABLE_DICOM_CACHE == 0 |
466 static std::auto_ptr<IDynamicObject> p; | 467 static std::auto_ptr<IDynamicObject> p; |
467 p.reset(provider_.Provide(instancePublicId)); | 468 p.reset(provider_.Provide(instancePublicId)); |
468 dicom_ = dynamic_cast<ParsedDicomFile*>(p.get()); | 469 dicom_ = dynamic_cast<ParsedDicomFile*>(p.get()); |
469 #else | 470 #else |
470 that_.dicomCacheMutex_.lock(); | |
471 dicom_ = &dynamic_cast<ParsedDicomFile&>(that_.dicomCache_.Access(instancePublicId)); | 471 dicom_ = &dynamic_cast<ParsedDicomFile&>(that_.dicomCache_.Access(instancePublicId)); |
472 #endif | 472 #endif |
473 } | 473 } |
474 | 474 |
475 | 475 |
476 ServerContext::DicomCacheLocker::~DicomCacheLocker() | 476 ServerContext::DicomCacheLocker::~DicomCacheLocker() |
477 { | 477 { |
478 #if ENABLE_DICOM_CACHE == 0 | |
479 #else | |
480 that_.dicomCacheMutex_.unlock(); | |
481 #endif | |
482 } | 478 } |
483 | 479 |
484 | 480 |
485 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5) | 481 void ServerContext::SetStoreMD5ForAttachments(bool storeMD5) |
486 { | 482 { |