# HG changeset patch # User Sebastien Jodogne # Date 1607527066 -3600 # Node ID d527a081f92df3530db91f8ba5d78f464889b62e # Parent 1382c908d67c9432d01317ef51d5054f3108b644 Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks diff -r 1382c908d67c -r d527a081f92d NEWS --- a/NEWS Wed Dec 09 10:07:48 2020 +0100 +++ b/NEWS Wed Dec 09 16:17:46 2020 +0100 @@ -11,6 +11,11 @@ * "/instances" can be used to import ZIP archives provided in the POST body +Maintenance +----------- + +* Allow concurrency on the OrthancPluginRegisterIncomingHttpRequestFilter() callbacks + Version 1.8.1 (2020-12-07) ========================== diff -r 1382c908d67c -r d527a081f92d OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Dec 09 10:07:48 2020 +0100 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Dec 09 16:17:46 2020 +0100 @@ -930,6 +930,7 @@ boost::mutex refreshMetricsMutex_; boost::mutex storageCommitmentScpMutex_; boost::recursive_mutex invokeServiceMutex_; + boost::shared_mutex incomingHttpRequestFilterMutex_; // New in Orthanc 1.9.0 Properties properties_; int argc_; @@ -2155,6 +2156,8 @@ const _OrthancPluginIncomingHttpRequestFilter& p = *reinterpret_cast(parameters); + boost::unique_lock lock(pimpl_->incomingHttpRequestFilterMutex_); + CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming HTTP requests"; pimpl_->incomingHttpRequestFilters_.push_back(p.callback); } @@ -2165,6 +2168,8 @@ const _OrthancPluginIncomingHttpRequestFilter2& p = *reinterpret_cast(parameters); + boost::unique_lock lock(pimpl_->incomingHttpRequestFilterMutex_); + CLOG(INFO, PLUGINS) << "Plugin has registered a callback to filter incoming HTTP requests"; pimpl_->incomingHttpRequestFilters2_.push_back(p.callback); } @@ -4423,6 +4428,14 @@ return true; } + case _OrthancPluginService_RegisterIncomingHttpRequestFilter: + RegisterIncomingHttpRequestFilter(parameters); + return true; + + case _OrthancPluginService_RegisterIncomingHttpRequestFilter2: + RegisterIncomingHttpRequestFilter2(parameters); + return true; + default: return false; } @@ -4484,14 +4497,6 @@ RegisterJobsUnserializer(parameters); return true; - case _OrthancPluginService_RegisterIncomingHttpRequestFilter: - RegisterIncomingHttpRequestFilter(parameters); - return true; - - case _OrthancPluginService_RegisterIncomingHttpRequestFilter2: - RegisterIncomingHttpRequestFilter2(parameters); - return true; - case _OrthancPluginService_RegisterIncomingDicomInstanceFilter: RegisterIncomingDicomInstanceFilter(parameters); return true; @@ -4940,7 +4945,7 @@ } { - boost::recursive_mutex::scoped_lock lock(pimpl_->invokeServiceMutex_); + boost::shared_lock lock(pimpl_->incomingHttpRequestFilterMutex_); // Improved callback with support for GET arguments, since Orthanc 1.3.0 for (PImpl::IncomingHttpRequestFilters2::const_iterator diff -r 1382c908d67c -r d527a081f92d OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h --- a/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Wed Dec 09 10:07:48 2020 +0100 +++ b/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h Wed Dec 09 16:17:46 2020 +0100 @@ -1267,6 +1267,10 @@ * ("false"), the server answers with HTTP status code 403 * (Forbidden). * + * Pay attention to the fact that this function may be invoked + * concurrently by different threads of the Web server of + * Orthanc. You must implement proper locking if applicable. + * * @param method The HTTP method used by the request. * @param uri The URI of interest. * @param ip The IP address of the HTTP client. @@ -1296,6 +1300,10 @@ * ("false"), the server answers with HTTP status code 403 * (Forbidden). * + * Pay attention to the fact that this function may be invoked + * concurrently by different threads of the Web server of + * Orthanc. You must implement proper locking if applicable. + * * @param method The HTTP method used by the request. * @param uri The URI of interest. * @param ip The IP address of the HTTP client.