changeset 1466:0cd0f2ad3599

Fix potential deadlock in the callbacks of plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 Jul 2015 09:11:37 +0200
parents 905842836ad4
children 5068de14eef1
files NEWS Plugins/Engine/OrthancPlugins.cpp Plugins/Include/orthanc/OrthancCDatabasePlugin.h Plugins/Include/orthanc/OrthancCPlugin.h
diffstat 4 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Jul 27 17:33:47 2015 +0200
+++ b/NEWS	Tue Jul 28 09:11:37 2015 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Fix access to binary data in HTTP/REST requests by Lua scripts
+* Fix potential deadlock in the callbacks of plugins
 
 
 Version 0.9.1 (2015/07/02)
--- a/Plugins/Engine/OrthancPlugins.cpp	Mon Jul 27 17:33:47 2015 +0200
+++ b/Plugins/Engine/OrthancPlugins.cpp	Tue Jul 28 09:11:37 2015 +0200
@@ -126,7 +126,9 @@
     OnChangeCallbacks  onChangeCallbacks_;
     bool hasStorageArea_;
     _OrthancPluginRegisterStorageArea storageArea_;
-    boost::recursive_mutex callbackMutex_;
+    boost::recursive_mutex restCallbackMutex_;
+    boost::recursive_mutex storedCallbackMutex_;
+    boost::recursive_mutex changeCallbackMutex_;
     Properties properties_;
     int argc_;
     char** argv_;
@@ -326,7 +328,7 @@
     int32_t error;
 
     {
-      boost::recursive_mutex::scoped_lock lock(pimpl_->callbackMutex_);
+      boost::recursive_mutex::scoped_lock lock(pimpl_->restCallbackMutex_);
       error = callback(reinterpret_cast<OrthancPluginRestOutput*>(&output), 
                        flatUri.c_str(), 
                        &request);
@@ -359,7 +361,7 @@
                                             DicomInstanceToStore& instance,
                                             const Json::Value& simplifiedTags)
   {
-    boost::recursive_mutex::scoped_lock lock(pimpl_->callbackMutex_);
+    boost::recursive_mutex::scoped_lock lock(pimpl_->storedCallbackMutex_);
 
     for (PImpl::OnStoredCallbacks::const_iterator
            callback = pimpl_->onStoredCallbacks_.begin(); 
@@ -376,7 +378,7 @@
   {
     try
     {
-      boost::recursive_mutex::scoped_lock lock(pimpl_->callbackMutex_);
+      boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_);
 
       for (std::list<OrthancPluginOnChangeCallback>::const_iterator 
              callback = pimpl_->onChangeCallbacks_.begin(); 
--- a/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Mon Jul 27 17:33:47 2015 +0200
+++ b/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Tue Jul 28 09:11:37 2015 +0200
@@ -1,3 +1,7 @@
+/**
+ * @defgroup CInterface C Interface 
+ **/
+
 /**
  * Orthanc - A Lightweight, RESTful DICOM Store
  * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
--- a/Plugins/Include/orthanc/OrthancCPlugin.h	Mon Jul 27 17:33:47 2015 +0200
+++ b/Plugins/Include/orthanc/OrthancCPlugin.h	Tue Jul 28 09:11:37 2015 +0200
@@ -14,7 +14,8 @@
  *    - Store the context pointer so that it can use the plugin 
  *      services of Orthanc.
  *    - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback().
- *    - Register all its callbacks for received instances using ::OrthancPluginRegisterOnStoredInstanceCallback().
+ *    - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback().
+ *    - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback().
  *    - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea().
  *    - Possibly register a custom database back-end area using ::OrthancPluginRegisterDatabaseBackend().
  * -# <tt>void OrthancPluginFinalize()</tt>:
@@ -28,7 +29,7 @@
  * The name and the version of a plugin is only used to prevent it
  * from being loaded twice.
  * 
- * The various callbacks are guaranteed to be executed in mutual
+ * The various REST callbacks are guaranteed to be executed in mutual
  * exclusion since Orthanc 0.8.5.
  **/