Mercurial > hg > orthanc
changeset 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 | ff0ed5ea9e4e |
children | 99863d6245b2 |
files | NEWS OrthancServer/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/QueryRetrieveHandler.cpp OrthancServer/QueryRetrieveHandler.h |
diffstat | 4 files changed, 31 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Sep 26 15:55:42 2018 +0200 +++ b/NEWS Thu Sep 27 13:22:57 2018 +0200 @@ -1,6 +1,10 @@ Pending changes in the mainline =============================== +Maintenance +----------- + +* Fix: Closing DICOM associations after running query/retrieve from REST API Version 1.4.2 (2018-09-20)
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Wed Sep 26 15:55:42 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Thu Sep 27 13:22:57 2018 +0200 @@ -430,7 +430,7 @@ Json::Value result = Json::objectValue; result["ID"] = s; result["Path"] = "/queries/" + s; - call.GetOutput().AnswerJson(result); + call.GetOutput().AnswerJson(result); } }
--- 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); } } }
--- a/OrthancServer/QueryRetrieveHandler.h Wed Sep 26 15:55:42 2018 +0200 +++ b/OrthancServer/QueryRetrieveHandler.h Thu Sep 27 13:22:57 2018 +0200 @@ -49,11 +49,11 @@ DicomFindAnswers answers_; std::string modalityName_; - std::auto_ptr<DicomUserConnection> connection_; - void Invalidate(); - DicomUserConnection& GetConnection(); + void RetrieveInternal(DicomUserConnection& connection, + const std::string& target, + size_t i); public: QueryRetrieveHandler(ServerContext& context);