Mercurial > hg > orthanc
changeset 1331:77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Mar 2015 10:47:32 +0100 |
parents | 7227b096a6dc |
children | f2033e228864 |
files | Core/DicomFormat/DicomMap.h NEWS OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/ServerIndex.cpp |
diffstat | 4 files changed, 34 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomFormat/DicomMap.h Wed Mar 11 16:57:01 2015 +0100 +++ b/Core/DicomFormat/DicomMap.h Thu Mar 12 10:47:32 2015 +0100 @@ -77,6 +77,11 @@ { Clear(); } + + size_t GetSize() const + { + return map_.size(); + } DicomMap* Clone() const;
--- a/NEWS Wed Mar 11 16:57:01 2015 +0100 +++ b/NEWS Thu Mar 12 10:47:32 2015 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Prevent freeze on C-FIND if no DICOM tag is to be returned + Version 0.8.6 (2015/02/12) ==========================
--- a/OrthancServer/OrthancFindRequestHandler.cpp Wed Mar 11 16:57:01 2015 +0100 +++ b/OrthancServer/OrthancFindRequestHandler.cpp Thu Mar 12 10:47:32 2015 +0100 @@ -197,7 +197,8 @@ static void AddAnswer(DicomFindAnswers& answers, const Json::Value& resource, - const DicomArray& query) + const DicomArray& query, + bool isFirst) { DicomMap result; @@ -220,7 +221,17 @@ } } - answers.Add(result); + if (result.GetSize() == 0) + { + if (isFirst) + { + LOG(WARNING) << "The C-FIND request does not return any DICOM tag"; + } + } + else + { + answers.Add(result); + } } @@ -563,7 +574,6 @@ std::list<std::string> resources; candidates.Flatten(resources); - LOG(INFO) << "Number of candidate resources after exact filtering: " << resources.size(); /** * Apply filtering on modalities for studies, if asked (this is an @@ -581,11 +591,14 @@ } } - /** * Loop over all the resources for this query level. **/ + LOG(INFO) << "Number of candidate resources after exact filtering on the identifiers only: " << resources.size(); + + bool isFirst = true; + for (std::list<std::string>::const_iterator resource = resources.begin(); resource != resources.end(); ++resource) { @@ -596,7 +609,7 @@ { Json::Value info; context_.ReadJson(info, instance); - + if (Matches(info, query)) { if (HasReachedLimit(answers, level)) @@ -605,7 +618,8 @@ return false; } - AddAnswer(answers, info, query); + AddAnswer(answers, info, query, isFirst); + isFirst = false; } } } @@ -615,6 +629,8 @@ } } + LOG(INFO) << "Number of candidate resources after filtering on all tags: " << answers.GetSize(); + return true; // All the matching resources have been returned } }
--- a/OrthancServer/ServerIndex.cpp Wed Mar 11 16:57:01 2015 +0100 +++ b/OrthancServer/ServerIndex.cpp Thu Mar 12 10:47:32 2015 +0100 @@ -148,7 +148,7 @@ virtual void SignalRemainingAncestor(ResourceType parentType, const std::string& publicId) { - LOG(INFO) << "Remaining ancestor \"" << publicId << "\" (" << parentType << ")"; + VLOG(1) << "Remaining ancestor \"" << publicId << "\" (" << parentType << ")"; if (hasRemainingLevel_) { @@ -175,9 +175,9 @@ virtual void SignalChange(const ServerIndexChange& change) { - LOG(INFO) << "Change related to resource " << change.GetPublicId() << " of type " - << EnumerationToString(change.GetResourceType()) << ": " - << EnumerationToString(change.GetChangeType()); + VLOG(1) << "Change related to resource " << change.GetPublicId() << " of type " + << EnumerationToString(change.GetResourceType()) << ": " + << EnumerationToString(change.GetChangeType()); if (insideTransaction_) { @@ -1316,7 +1316,7 @@ throw OrthancException(ErrorCode_FullStorage); } - LOG(INFO) << "Recycling one patient"; + VLOG(1) << "Recycling one patient"; db_.DeleteResource(patientToRecycle); if (!IsRecyclingNeeded(instanceSize))