Mercurial > hg > orthanc
changeset 6350:b98d11169577
ZipLoaderThreads: more logs and catch ...
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Fri, 24 Oct 2025 11:51:42 +0200 |
| parents | 4364c26b0339 |
| children | add962490217 |
| files | OrthancServer/Sources/ServerJobs/ArchiveJob.cpp |
| diffstat | 1 files changed, 32 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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<std::string>(threadCounter++)); + LOG(INFO) << "Loader thread has started"; + while (true) { std::unique_ptr<InstanceToPreload> instanceToPreload(dynamic_cast<InstanceToPreload*>(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<std::string>(); + 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<std::string>(); that->availableInstancesSemaphore_.Release(); } } + + LOG(INFO) << "Loader thread has completed"; } virtual void PrepareDicom(const std::string& instanceId, const FileInfo& fileInfo) ORTHANC_OVERRIDE
