# HG changeset patch # User Sebastien Jodogne # Date 1411656015 -7200 # Node ID cbd1f05b4ef26906075cbdebf3cd19d5eea8a01b # Parent c71d25e6a63c5a61b8af3eec165a1c9dbc479983 plugin callbacks are executed in mutual exclusion diff -r c71d25e6a63c -r cbd1f05b4ef2 Plugins/Engine/OrthancPlugins.cpp --- a/Plugins/Engine/OrthancPlugins.cpp Wed Sep 24 17:40:29 2014 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Thu Sep 25 16:40:15 2014 +0200 @@ -40,6 +40,7 @@ #include "../../OrthancServer/ServerToolbox.h" #include "../../OrthancServer/OrthancInitialization.h" +#include #include #include @@ -93,6 +94,7 @@ OnChangeCallbacks onChangeCallbacks_; bool hasStorageArea_; _OrthancPluginRegisterStorageArea storageArea_; + boost::mutex callbackMutex_; PImpl(ServerContext& context) : context_(context), @@ -336,9 +338,14 @@ } assert(callback != NULL); - int32_t error = callback(reinterpret_cast(&output), - flatUri.c_str(), - &request); + int32_t error; + + { + boost::mutex::scoped_lock lock(pimpl_->callbackMutex_); + error = callback(reinterpret_cast(&output), + flatUri.c_str(), + &request); + } if (error < 0) { @@ -360,6 +367,8 @@ void OrthancPlugins::SignalStoredInstance(DicomInstanceToStore& instance, const std::string& instanceId) { + boost::mutex::scoped_lock lock(pimpl_->callbackMutex_); + for (PImpl::OnStoredCallbacks::const_iterator callback = pimpl_->onStoredCallbacks_.begin(); callback != pimpl_->onStoredCallbacks_.end(); ++callback) @@ -389,6 +398,8 @@ return; } + boost::mutex::scoped_lock lock(pimpl_->callbackMutex_); + for (PImpl::OnChangeCallbacks::const_iterator callback = pimpl_->onChangeCallbacks_.begin(); callback != pimpl_->onChangeCallbacks_.end(); ++callback)