Mercurial > hg > orthanc
changeset 1185:cbd1f05b4ef2 db-changes
plugin callbacks are executed in mutual exclusion
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Sep 2014 16:40:15 +0200 |
parents | c71d25e6a63c |
children | 49edef619f1f |
files | Plugins/Engine/OrthancPlugins.cpp |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 <boost/thread.hpp> #include <boost/regex.hpp> #include <glog/logging.h> @@ -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<OrthancPluginRestOutput*>(&output), - flatUri.c_str(), - &request); + int32_t error; + + { + boost::mutex::scoped_lock lock(pimpl_->callbackMutex_); + error = callback(reinterpret_cast<OrthancPluginRestOutput*>(&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)