# HG changeset patch # User Alain Mazy # Date 1761299502 -7200 # Node ID b98d111695779001c49c3c24cf932b6d4496768e # Parent 4364c26b0339d9ee78567cbe2a4281aec3dc600f ZipLoaderThreads: more logs and catch ... diff -r 4364c26b0339 -r b98d11169577 OrthancServer/Sources/ServerJobs/ArchiveJob.cpp --- a/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Thu Oct 23 10:23:51 2025 +0200 +++ b/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Fri Oct 24 11:51:42 2025 +0200 @@ -212,22 +212,29 @@ virtual void Clear() ORTHANC_OVERRIDE { - for (size_t i = 0; i < threads_.size(); i++) - { - instancesToPreload_.Enqueue(NULL); - } - - for (size_t i = 0; i < threads_.size(); i++) + if (threads_.size() > 0) { - if (threads_[i]->joinable()) + LOG(INFO) << "Waiting for loader threads to complete"; + + for (size_t i = 0; i < threads_.size(); i++) { - threads_[i]->join(); + instancesToPreload_.Enqueue(NULL); } - delete threads_[i]; - } - threads_.clear(); - availableInstances_.clear(); + for (size_t i = 0; i < threads_.size(); i++) + { + if (threads_[i]->joinable()) + { + threads_[i]->join(); + } + delete threads_[i]; + } + + threads_.clear(); + availableInstances_.clear(); + + LOG(INFO) << "Waiting for loader threads to complete - done"; + } } static void PreloaderWorkerThread(ThreadedInstanceLoader* that) @@ -235,6 +242,8 @@ static uint16_t threadCounter = 0; Logging::SetCurrentThreadName(std::string("ARCH-LOAD-") + boost::lexical_cast(threadCounter++)); + LOG(INFO) << "Loader thread has started"; + while (true) { std::unique_ptr instanceToPreload(dynamic_cast(that->instancesToPreload_.Dequeue(0))); @@ -269,12 +278,23 @@ } catch (OrthancException& e) { + LOG(ERROR) << "Failed to load instance " << instanceToPreload->GetId() << " error: " << e.GetDetails(); + boost::mutex::scoped_lock lock(that->availableInstancesMutex_); + // store a NULL result to notify that we could not read the instance + that->availableInstances_[instanceToPreload->GetId()] = boost::shared_ptr(); + that->availableInstancesSemaphore_.Release(); + } + catch (...) + { + LOG(ERROR) << "Failed to load instance " << instanceToPreload->GetId() << " unknown error"; boost::mutex::scoped_lock lock(that->availableInstancesMutex_); // store a NULL result to notify that we could not read the instance that->availableInstances_[instanceToPreload->GetId()] = boost::shared_ptr(); that->availableInstancesSemaphore_.Release(); } } + + LOG(INFO) << "Loader thread has completed"; } virtual void PrepareDicom(const std::string& instanceId, const FileInfo& fileInfo) ORTHANC_OVERRIDE