Mercurial > hg > orthanc
diff OrthancServer/QueryRetrieveHandler.cpp @ 2843:4ee3a759afea
Fix: Closing DICOM associations after running query/retrieve from REST API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Sep 2018 13:22:57 +0200 |
parents | 912a767911b0 |
children | 251614c2edac |
line wrap: on
line diff
--- a/OrthancServer/QueryRetrieveHandler.cpp Wed Sep 26 15:55:42 2018 +0200 +++ b/OrthancServer/QueryRetrieveHandler.cpp Thu Sep 27 13:22:57 2018 +0200 @@ -79,19 +79,6 @@ { done_ = false; answers_.Clear(); - connection_.reset(NULL); - } - - - DicomUserConnection& QueryRetrieveHandler::GetConnection() - { - if (connection_.get() == NULL) - { - connection_.reset(new DicomUserConnection(localAet_, modality_)); - connection_->Open(); - } - - return *connection_; } @@ -107,7 +94,11 @@ // Secondly, possibly fix the query with the user-provider Lua callback FixQueryLua(fixed, context_, modality_.GetApplicationEntityTitle()); - GetConnection().Find(answers_, level_, fixed); + { + DicomUserConnection connection(localAet_, modality_); + connection.Open(); + connection.Find(answers_, level_, fixed); + } done_ = true; } @@ -162,20 +153,34 @@ } + void QueryRetrieveHandler::RetrieveInternal(DicomUserConnection& connection, + const std::string& target, + size_t i) + { + DicomMap map; + GetAnswer(map, i); + connection.Move(target, map); + } + + void QueryRetrieveHandler::Retrieve(const std::string& target, size_t i) { - DicomMap map; - GetAnswer(map, i); - GetConnection().Move(target, map); + DicomUserConnection connection(localAet_, modality_); + connection.Open(); + + RetrieveInternal(connection, target, i); } void QueryRetrieveHandler::Retrieve(const std::string& target) { + DicomUserConnection connection(localAet_, modality_); + connection.Open(); + for (size_t i = 0; i < GetAnswerCount(); i++) { - Retrieve(target, i); + RetrieveInternal(connection, target, i); } } }