changeset 2590:5e2730c8e23c jobs

getting rid of ReusableDicomConnection in QueryRetrieveHandler and OrthancMoveRequestHandler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 15 May 2018 16:28:43 +0200
parents a3fdfb6979ed
children 441f23af9d89
files OrthancServer/OrthancMoveRequestHandler.cpp OrthancServer/QueryRetrieveHandler.cpp OrthancServer/QueryRetrieveHandler.h
diffstat 3 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancMoveRequestHandler.cpp	Tue May 15 16:10:03 2018 +0200
+++ b/OrthancServer/OrthancMoveRequestHandler.cpp	Tue May 15 16:28:43 2018 +0200
@@ -55,6 +55,7 @@
       RemoteModalityParameters remote_;
       std::string originatorAet_;
       uint16_t originatorId_;
+      std::auto_ptr<DicomUserConnection> connection_;
 
     public:
       OrthancMoveRequestIterator(ServerContext& context,
@@ -99,12 +100,13 @@
         std::string dicom;
         context_.ReadDicom(dicom, id);
 
+        if (connection_.get() == NULL)
         {
-          ReusableDicomUserConnection::Locker locker
-            (context_.GetReusableDicomUserConnection(), localAet_, remote_);
-          locker.GetConnection().Store(dicom, originatorAet_, originatorId_);
+          connection_.reset(new DicomUserConnection(localAet_, remote_));
         }
 
+        connection_->Store(dicom, originatorAet_, originatorId_);
+
         return Status_Success;
       }
     };
--- a/OrthancServer/QueryRetrieveHandler.cpp	Tue May 15 16:10:03 2018 +0200
+++ b/OrthancServer/QueryRetrieveHandler.cpp	Tue May 15 16:28:43 2018 +0200
@@ -76,6 +76,19 @@
   {
     done_ = false;
     answers_.Clear();
+    connection_.reset(NULL);
+  }
+
+
+  DicomUserConnection& QueryRetrieveHandler::GetConnection()
+  {
+    if (connection_.get() == NULL)
+    {
+      connection_.reset(new DicomUserConnection(localAet_, modality_));
+      connection_->Open();
+    }
+
+    return *connection_;
   }
 
 
@@ -91,11 +104,7 @@
       // Secondly, possibly fix the query with the user-provider Lua callback
       FixQuery(fixed, context_, modality_.GetApplicationEntityTitle()); 
 
-      {
-        // Finally, run the C-FIND SCU against the fixed query
-        ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), localAet_, modality_);
-        locker.GetConnection().Find(answers_, level_, fixed);
-      }
+      GetConnection().Find(answers_, level_, fixed);
 
       done_ = true;
     }
@@ -155,11 +164,7 @@
   {
     DicomMap map;
     GetAnswer(map, i);
-
-    {
-      ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), localAet_, modality_);
-      locker.GetConnection().Move(target, map);
-    }
+    GetConnection().Move(target, map);
   }
 
 
--- a/OrthancServer/QueryRetrieveHandler.h	Tue May 15 16:10:03 2018 +0200
+++ b/OrthancServer/QueryRetrieveHandler.h	Tue May 15 16:28:43 2018 +0200
@@ -49,8 +49,11 @@
     DicomFindAnswers           answers_;
     std::string                modalityName_;
 
+    std::auto_ptr<DicomUserConnection>  connection_;
+
     void Invalidate();
 
+    DicomUserConnection& GetConnection();
 
   public:
     QueryRetrieveHandler(ServerContext& context);