# HG changeset patch # User Alain Mazy # Date 1776856168 -7200 # Node ID cba457078ce808b0b28ba1ca45097b586e4300e5 # Parent 73cb29fd7eb560137c1e8a8728009a13bc5c9128 lazy starting of loader threads in StoreJob + fix OrthancPeerStore loader threads usage diff -r 73cb29fd7eb5 -r cba457078ce8 NEWS --- a/NEWS Wed Apr 22 12:26:28 2026 +0200 +++ b/NEWS Wed Apr 22 13:09:28 2026 +0200 @@ -25,8 +25,10 @@ Maintenance ----------- -* Fix /jobs/.../resubmit for OrthancPeerStore and DicomModalityStore jobs +* Fix resubmit/pause/cancel and reloading of OrthancPeerStore and DicomModalityStore jobs (bug introduced in 1.12.10) +* Fix OrthancPeerStore jobs that was using the loader threads only if transcoding + was required. * Fix Orthanc::ImageAccessor that was broken in Orthanc Framework 1.12.11 diff -r 73cb29fd7eb5 -r cba457078ce8 OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp --- a/OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp Wed Apr 22 12:26:28 2026 +0200 +++ b/OrthancServer/Sources/ServerJobs/DicomModalityStoreJob.cpp Wed Apr 22 13:09:28 2026 +0200 @@ -48,6 +48,11 @@ assert(IsStarted()); OpenConnection(); + if (instancesLoader_.get() == NULL) + { + StartLoaderThreads(); + } + LOG(INFO) << "Sending instance " << instance << " to modality \"" << parameters_.GetRemoteModality().GetApplicationEntityTitle() << "\""; diff -r 73cb29fd7eb5 -r cba457078ce8 OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp --- a/OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp Wed Apr 22 12:26:28 2026 +0200 +++ b/OrthancServer/Sources/ServerJobs/OrthancPeerStoreJob.cpp Wed Apr 22 13:09:28 2026 +0200 @@ -36,7 +36,10 @@ { bool OrthancPeerStoreJob::HandleInstance(const std::string& instance) { - //boost::this_thread::sleep(boost::posix_time::milliseconds(500)); + if (instancesLoader_.get() == NULL) + { + StartLoaderThreads(); + } if (client_.get() == NULL) { @@ -58,11 +61,11 @@ try { + std::string dicom; + instancesLoader_->WaitDicomInstance(dicom, instance); + if (transcode_) { - std::string dicom; - instancesLoader_->WaitDicomInstance(dicom, instance); - std::set syntaxes; syntaxes.insert(transferSyntax_); @@ -81,7 +84,7 @@ } else { - context_.ReadDicom(body, instance); + body.swap(dicom); } } catch (OrthancException& e) diff -r 73cb29fd7eb5 -r cba457078ce8 OrthancServer/Sources/ServerJobs/StoreJob.cpp --- a/OrthancServer/Sources/ServerJobs/StoreJob.cpp Wed Apr 22 12:26:28 2026 +0200 +++ b/OrthancServer/Sources/ServerJobs/StoreJob.cpp Wed Apr 22 13:09:28 2026 +0200 @@ -81,16 +81,8 @@ } } - void StoreJob::Reset() // called in case of "resubmit" - { - SetOfInstancesJob::Reset(); - - // restart the loader threads here (this can happen quite long before the job starts actually being executed but this is the only place where we can do this) - Start(); - } - - void StoreJob::Start() + void StoreJob::StartLoaderThreads() { size_t loaderThreads = 1; { @@ -105,23 +97,12 @@ { instancesLoader_->PreloadDicomInstance(instancesIds_[i], filesInfo_[i]); } - - SetOfInstancesJob::Start(); } - - void StoreJob::Stop(JobStopReason reason) // For pausing jobs + + void StoreJob::Stop(JobStopReason reason) { - if (reason == JobStopReason_Canceled || - reason == JobStopReason_Failure || - reason == JobStopReason_Retry || - reason == JobStopReason_Success) - { - // clear the loader threads - if (instancesLoader_.get() != NULL) - { - instancesLoader_->Clear(true); - } - } + // clear the loader threads (also when simply pausing the job) + instancesLoader_.reset(NULL); } } diff -r 73cb29fd7eb5 -r cba457078ce8 OrthancServer/Sources/ServerJobs/StoreJob.h --- a/OrthancServer/Sources/ServerJobs/StoreJob.h Wed Apr 22 12:26:28 2026 +0200 +++ b/OrthancServer/Sources/ServerJobs/StoreJob.h Wed Apr 22 13:09:28 2026 +0200 @@ -44,16 +44,14 @@ virtual const char* GetLoaderPrefix() const = 0; + void StartLoaderThreads(); + public: explicit StoreJob(ServerContext& context); StoreJob(ServerContext& context, const Json::Value& serialized); - virtual void Reset() ORTHANC_OVERRIDE; - - virtual void Start() ORTHANC_OVERRIDE; - virtual void Stop(JobStopReason reason) ORTHANC_OVERRIDE; void AddInstances(const std::vector& instancesIds,