# HG changeset patch # User Alain Mazy # Date 1764942837 -3600 # Node ID 94c7f37844560ab266b79a73bdf08ee587245561 # Parent aa11cc4c14a57fb2ae7c306ae9297fb90d96a932 improved thread safety of OrthancPlugins::OrthancJob diff -r aa11cc4c14a5 -r 94c7f3784456 OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Fri Dec 05 10:08:40 2025 +0100 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Fri Dec 05 14:53:57 2025 +0100 @@ -2441,6 +2441,8 @@ { assert(job != NULL); OrthancJob& that = *reinterpret_cast(job); + + boost::mutex::scoped_lock lock(that.contentMutex_); return CopyStringToMemoryBuffer(target, that.content_); } #else @@ -2450,7 +2452,10 @@ try { - return reinterpret_cast(job)->content_.c_str(); + OrthancJob& that = *reinterpret_cast(job); + boost::mutex::scoped_lock lock(that.contentMutex_); + + return that.content_.c_str(); } catch (...) { @@ -2578,6 +2583,8 @@ void OrthancJob::UpdateContent(const Json::Value& content) { + boost::mutex::scoped_lock lock(contentMutex_); + if (content.type() != Json::objectValue) { ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_BadFileFormat); diff -r aa11cc4c14a5 -r 94c7f3784456 OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h --- a/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Fri Dec 05 10:08:40 2025 +0100 +++ b/OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.h Fri Dec 05 14:53:57 2025 +0100 @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -943,6 +944,7 @@ { private: std::string jobType_; + boost::mutex contentMutex_; std::string content_; bool hasSerialized_; std::string serialized_;