# HG changeset patch # User Sebastien Jodogne # Date 1779037237 -7200 # Node ID 4514943d9239c94012de4572a4d40d744dedf509 # Parent 323f93009cc858008acbef6ccebf91f9afe0259f added mutex to DicomDataSource::Dicom diff -r 323f93009cc8 -r 4514943d9239 OrthancFramework/UnitTestsSources/JobsTests.cpp --- a/OrthancFramework/UnitTestsSources/JobsTests.cpp Sun May 17 18:54:12 2026 +0200 +++ b/OrthancFramework/UnitTestsSources/JobsTests.cpp Sun May 17 19:00:37 2026 +0200 @@ -2064,10 +2064,10 @@ } - // TODO - Add mutex and accessor class Dicom : public boost::noncopyable { private: + boost::mutex mutex_; boost::shared_ptr value_; public: @@ -2080,10 +2080,29 @@ } } - ParsedDicomFile& GetContent() const + /** + * Access to the DICOM value must be protected by a mutex, as it + * could be shared by multiple threads if caching is enabled in + * the DataSourceReader. + **/ + class Lock : public boost::noncopyable { - return dynamic_cast(*value_).GetDicom(); - } + private: + Dicom& that_; + boost::mutex::scoped_lock lock_; + + public: + explicit Lock(Dicom& that) : + that_(that), + lock_(that.mutex_) + { + } + + ParsedDicomFile& GetContent() const + { + return dynamic_cast(*that_.value_).GetDicom(); + } + }; }; static Dicom* ReadWhole(DataSourceReader& reader,