changeset 1284:21ea32170764

Option "DicomAssociationCloseDelay" to set delay before closing DICOM association
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Feb 2015 14:07:07 +0100
parents 6066529e34c8
children 5730f374e4e6
files NEWS OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp OrthancServer/DicomProtocol/ReusableDicomUserConnection.h OrthancServer/ServerContext.cpp Resources/Configuration.json
diffstat 5 files changed, 27 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Feb 03 13:15:46 2015 +0100
+++ b/NEWS	Tue Feb 03 14:07:07 2015 +0100
@@ -1,16 +1,20 @@
 Pending changes in the mainline
 ===============================
 
-General
--------
+Major
+-----
 
 * URIs to get all the parents of a given resource in a single REST call
 * Support of HTTP proxy
 * Instances without PatientID are now allowed
+
+Minor
+-----
 * Support of Tudor DICOM in Query/Retrieve
 * Fix issue 25 (AET with underscore not allowed)
+* More flexible "/modify" and "/anonymize" for single instance
 * Code refactorings
-* More flexible "/modify" and "/anonymize" for single instance
+* Option "DicomAssociationCloseDelay" to set delay before closing DICOM association
 
 Plugins
 -------
--- a/OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp	Tue Feb 03 13:15:46 2015 +0100
+++ b/OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp	Tue Feb 03 14:07:07 2015 +0100
@@ -152,9 +152,15 @@
     Close();
   }
 
-  void ReusableDicomUserConnection::SetMillisecondsBeforeClose(unsigned int ms)
+  void ReusableDicomUserConnection::SetMillisecondsBeforeClose(uint64_t ms)
   {
     boost::mutex::scoped_lock lock(mutex_);
+
+    if (ms == 0)
+    {
+      ms = 1;
+    }
+
     timeBeforeClose_ = boost::posix_time::milliseconds(ms);
   }
 
--- a/OrthancServer/DicomProtocol/ReusableDicomUserConnection.h	Tue Feb 03 13:15:46 2015 +0100
+++ b/OrthancServer/DicomProtocol/ReusableDicomUserConnection.h	Tue Feb 03 14:07:07 2015 +0100
@@ -88,12 +88,12 @@
 
     virtual ~ReusableDicomUserConnection();
 
-    unsigned int GetMillisecondsBeforeClose() const
+    uint64_t GetMillisecondsBeforeClose() const
     {
-      return static_cast<unsigned int>(timeBeforeClose_.total_milliseconds());
+      return static_cast<uint64_t>(timeBeforeClose_.total_milliseconds());
     }
 
-    void SetMillisecondsBeforeClose(unsigned int ms);
+    void SetMillisecondsBeforeClose(uint64_t ms);
 
     const std::string& GetLocalApplicationEntityTitle() const;
 
--- a/OrthancServer/ServerContext.cpp	Tue Feb 03 13:15:46 2015 +0100
+++ b/OrthancServer/ServerContext.cpp	Tue Feb 03 14:07:07 2015 +0100
@@ -81,7 +81,9 @@
     pluginsManager_(NULL)
   {
     scu_.SetLocalApplicationEntityTitle(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC"));
-    //scu_.SetMillisecondsBeforeClose(1);  // The connection is always released
+
+    uint64_t s = Configuration::GetGlobalIntegerParameter("DicomAssociationCloseDelay", 5);  // In seconds
+    scu_.SetMillisecondsBeforeClose(s * 1000);  // Milliseconds are expected here
 
     lua_.Execute(Orthanc::EmbeddedResources::LUA_TOOLBOX);
     lua_.SetHttpProxy(Configuration::GetGlobalStringParameter("HttpProxy", ""));
--- a/Resources/Configuration.json	Tue Feb 03 13:15:46 2015 +0100
+++ b/Resources/Configuration.json	Tue Feb 03 14:07:07 2015 +0100
@@ -216,5 +216,11 @@
 
   // If this option is set to "false", Orthanc will run in index-only
   // mode. The DICOM files will not be stored on the drive.
-  "StoreDicom" : true
+  "StoreDicom" : true,
+
+  // DICOM associations are kept open as long as new DICOM commands
+  // are issued. This option sets the number of seconds of inactivity
+  // to wait before automatically closing a DICOM association. If set
+  // to 0, the connection is closed immediately.
+  "DicomAssociationCloseDelay" : 5
 }