changeset 2580:055d7d4a823f jobs

avoid unecessary openings of DICOM connection for C-Store
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 May 2018 09:35:17 +0200
parents 6783a7c02990
children 8da2cffc2378
files Core/DicomNetworking/DicomUserConnection.cpp Core/HttpServer/MongooseServer.cpp OrthancServer/OrthancRestApi/OrthancRestModalities.cpp UnitTestsSources/MultiThreadingTests.cpp
diffstat 4 files changed, 31 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomUserConnection.cpp	Fri May 11 08:54:56 2018 +0200
+++ b/Core/DicomNetworking/DicomUserConnection.cpp	Fri May 11 09:35:17 2018 +0200
@@ -264,8 +264,6 @@
                                          const std::string& moveOriginatorAET,
                                          uint16_t moveOriginatorID)
   {
-    CheckIsOpen();
-
     DcmFileFormat dcmff;
     Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength));
 
@@ -284,23 +282,36 @@
     bool isGeneric = IsGenericTransferSyntax(syntax);
 
     bool renegotiate;
-    if (isGeneric)
+
+    if (!IsOpen())
+    {
+      renegotiate = true;
+    }
+    else if (isGeneric)
     {
       // Are we making a generic-to-specific or specific-to-generic change of
       // the transfer syntax? If this is the case, renegotiate the connection.
       renegotiate = !IsGenericTransferSyntax(connection.GetPreferredTransferSyntax());
+
+      if (renegotiate)
+      {
+        LOG(INFO) << "Use of non-generic transfer syntax: the C-Store associated must be renegotiated";
+      }
     }
     else
     {
       // We are using a specific transfer syntax. Renegotiate if the
       // current connection does not match this transfer syntax.
       renegotiate = (syntax != connection.GetPreferredTransferSyntax());
+
+      if (renegotiate)
+      {
+        LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated";
+      }
     }
 
     if (renegotiate)
     {
-      LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated";
-
       if (isGeneric)
       {
         connection.ResetPreferredTransferSyntax();
@@ -313,7 +324,6 @@
 
     if (!connection.IsOpen())
     {
-      LOG(INFO) << "Renegotiating a C-Store association due to a change in the parameters";
       connection.Open();
     }
 
--- a/Core/HttpServer/MongooseServer.cpp	Fri May 11 08:54:56 2018 +0200
+++ b/Core/HttpServer/MongooseServer.cpp	Fri May 11 09:35:17 2018 +0200
@@ -969,7 +969,7 @@
         // https://groups.google.com/d/msg/orthanc-users/CKueKX0pJ9E/_UCbl8T-VjIJ
         "enable_keep_alive", (keepAlive_ ? "yes" : "no"),
 
-if ORTHANC_ENABLE_CIVETWEB == 1
+#if ORTHANC_ENABLE_CIVETWEB == 1
         // https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md#enable_keep_alive-no
         "keep_alive_timeout_ms", (keepAlive_ ? "500" : "0"),
 #endif
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Fri May 11 08:54:56 2018 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Fri May 11 09:35:17 2018 +0200
@@ -157,14 +157,13 @@
     std::auto_ptr<DicomUserConnection>  connection_;
     std::set<std::string>               failedInstances_;
 
-    void Open()
+    void CreateConnection()
     {
       if (connection_.get() == NULL)
       {
         connection_.reset(new DicomUserConnection);
         connection_->SetLocalApplicationEntityTitle(localAet_);
         connection_->SetRemoteModality(remote_);
-        connection_->Open();
       }
     }
     
@@ -299,7 +298,7 @@
         return new JobStepResult(JobStepCode_Success);
       }
 
-      Open();
+      CreateConnection();
 
       bool ok = false;
       
--- a/UnitTestsSources/MultiThreadingTests.cpp	Fri May 11 08:54:56 2018 +0200
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Fri May 11 09:35:17 2018 +0200
@@ -291,7 +291,16 @@
     return static_cast<float>(count_) / static_cast<float>(steps_ - 1);
   }
 
-  virtual void GetDescription(Json::Value& value)
+  virtual void GetJobType(std::string& type)
+  {
+    type = "DummyJob";
+  }
+
+  virtual void GetInternalContent(Json::Value& value)
+  {
+  }
+
+  virtual void GetPublicContent(Json::Value& value)
   {
     value["hello"] = "world";
   }
@@ -632,7 +641,7 @@
       if (engine.GetRegistry().GetJobInfo(info, *it))
       {
         Json::Value vv;
-        info.Format(vv);
+        info.Serialize(vv);
         v.append(vv);
       }
     }
@@ -668,7 +677,7 @@
       if (engine.GetRegistry().GetJobInfo(info, *it))
       {
         Json::Value vv;
-        info.Format(vv);
+        info.Serialize(vv);
         v.append(vv);
       }
     }