# HG changeset patch # User Sebastien Jodogne # Date 1426153652 -3600 # Node ID 77e129ba64e4558d83d1b4b39afad4c7d35dd7ae # Parent 7227b096a6dc44ac3c9c40eafc972bfd98d15931 Prevent freeze on C-FIND if no DICOM tag is to be returned diff -r 7227b096a6dc -r 77e129ba64e4 Core/DicomFormat/DicomMap.h --- 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; diff -r 7227b096a6dc -r 77e129ba64e4 NEWS --- 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) ========================== diff -r 7227b096a6dc -r 77e129ba64e4 OrthancServer/OrthancFindRequestHandler.cpp --- 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 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::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 } } diff -r 7227b096a6dc -r 77e129ba64e4 OrthancServer/ServerIndex.cpp --- 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))