Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 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 | b737acb13da5 |
children | f967bdf8534e |
comparison
equal
deleted
inserted
replaced
1465:905842836ad4 | 1466:0cd0f2ad3599 |
---|---|
124 RestCallbacks restCallbacks_; | 124 RestCallbacks restCallbacks_; |
125 OnStoredCallbacks onStoredCallbacks_; | 125 OnStoredCallbacks onStoredCallbacks_; |
126 OnChangeCallbacks onChangeCallbacks_; | 126 OnChangeCallbacks onChangeCallbacks_; |
127 bool hasStorageArea_; | 127 bool hasStorageArea_; |
128 _OrthancPluginRegisterStorageArea storageArea_; | 128 _OrthancPluginRegisterStorageArea storageArea_; |
129 boost::recursive_mutex callbackMutex_; | 129 boost::recursive_mutex restCallbackMutex_; |
130 boost::recursive_mutex storedCallbackMutex_; | |
131 boost::recursive_mutex changeCallbackMutex_; | |
130 Properties properties_; | 132 Properties properties_; |
131 int argc_; | 133 int argc_; |
132 char** argv_; | 134 char** argv_; |
133 std::auto_ptr<OrthancPluginDatabase> database_; | 135 std::auto_ptr<OrthancPluginDatabase> database_; |
134 | 136 |
324 | 326 |
325 assert(callback != NULL); | 327 assert(callback != NULL); |
326 int32_t error; | 328 int32_t error; |
327 | 329 |
328 { | 330 { |
329 boost::recursive_mutex::scoped_lock lock(pimpl_->callbackMutex_); | 331 boost::recursive_mutex::scoped_lock lock(pimpl_->restCallbackMutex_); |
330 error = callback(reinterpret_cast<OrthancPluginRestOutput*>(&output), | 332 error = callback(reinterpret_cast<OrthancPluginRestOutput*>(&output), |
331 flatUri.c_str(), | 333 flatUri.c_str(), |
332 &request); | 334 &request); |
333 } | 335 } |
334 | 336 |
357 | 359 |
358 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId, | 360 void OrthancPlugins::SignalStoredInstance(const std::string& instanceId, |
359 DicomInstanceToStore& instance, | 361 DicomInstanceToStore& instance, |
360 const Json::Value& simplifiedTags) | 362 const Json::Value& simplifiedTags) |
361 { | 363 { |
362 boost::recursive_mutex::scoped_lock lock(pimpl_->callbackMutex_); | 364 boost::recursive_mutex::scoped_lock lock(pimpl_->storedCallbackMutex_); |
363 | 365 |
364 for (PImpl::OnStoredCallbacks::const_iterator | 366 for (PImpl::OnStoredCallbacks::const_iterator |
365 callback = pimpl_->onStoredCallbacks_.begin(); | 367 callback = pimpl_->onStoredCallbacks_.begin(); |
366 callback != pimpl_->onStoredCallbacks_.end(); ++callback) | 368 callback != pimpl_->onStoredCallbacks_.end(); ++callback) |
367 { | 369 { |
374 | 376 |
375 void OrthancPlugins::SignalChange(const ServerIndexChange& change) | 377 void OrthancPlugins::SignalChange(const ServerIndexChange& change) |
376 { | 378 { |
377 try | 379 try |
378 { | 380 { |
379 boost::recursive_mutex::scoped_lock lock(pimpl_->callbackMutex_); | 381 boost::recursive_mutex::scoped_lock lock(pimpl_->changeCallbackMutex_); |
380 | 382 |
381 for (std::list<OrthancPluginOnChangeCallback>::const_iterator | 383 for (std::list<OrthancPluginOnChangeCallback>::const_iterator |
382 callback = pimpl_->onChangeCallbacks_.begin(); | 384 callback = pimpl_->onChangeCallbacks_.begin(); |
383 callback != pimpl_->onChangeCallbacks_.end(); ++callback) | 385 callback != pimpl_->onChangeCallbacks_.end(); ++callback) |
384 { | 386 { |