# HG changeset patch # User Sebastien Jodogne # Date 1435844664 -7200 # Node ID 68827c07e6830a0c470ce4ab947bfd845f7e703f # Parent a685457679754326e1b9b63f005885861036e5ee fix recursive calls with Lua diff -r a68545767975 -r 68827c07e683 OrthancServer/LuaScripting.cpp --- a/OrthancServer/LuaScripting.cpp Thu Jul 02 15:17:19 2015 +0200 +++ b/OrthancServer/LuaScripting.cpp Thu Jul 02 15:44:24 2015 +0200 @@ -390,7 +390,7 @@ DicomInstanceToStore& instance, const Json::Value& simplifiedTags) { - boost::mutex::scoped_lock lock(mutex_); + boost::recursive_mutex::scoped_lock lock(mutex_); Json::Value metadata = Json::objectValue; @@ -437,7 +437,7 @@ if (context_.GetIndex().LookupResource(tags, change.GetPublicId(), change.GetResourceType()) && context_.GetIndex().GetMetadata(metadata, change.GetPublicId())) { - boost::mutex::scoped_lock lock(mutex_); + boost::recursive_mutex::scoped_lock lock(mutex_); if (lua_.IsExistingFunction(name)) { @@ -472,7 +472,7 @@ { static const char* NAME = "ReceivedInstanceFilter"; - boost::mutex::scoped_lock lock(mutex_); + boost::recursive_mutex::scoped_lock lock(mutex_); if (lua_.IsExistingFunction(NAME)) { diff -r a68545767975 -r 68827c07e683 OrthancServer/LuaScripting.h --- a/OrthancServer/LuaScripting.h Thu Jul 02 15:17:19 2015 +0200 +++ b/OrthancServer/LuaScripting.h Thu Jul 02 15:44:24 2015 +0200 @@ -67,7 +67,7 @@ void OnStableResource(const ServerIndexChange& change); - boost::mutex mutex_; + boost::recursive_mutex mutex_; LuaContext lua_; ServerContext& context_; @@ -76,16 +76,13 @@ { private: LuaScripting& that_; + boost::recursive_mutex::scoped_lock lock_; public: - Locker(LuaScripting& that) : that_(that) + Locker(LuaScripting& that) : + that_(that), + lock_(that.mutex_) { - that.mutex_.lock(); - } - - ~Locker() - { - that_.mutex_.unlock(); } LuaContext& GetLua() diff -r a68545767975 -r 68827c07e683 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Thu Jul 02 15:17:19 2015 +0200 +++ b/OrthancServer/ServerContext.cpp Thu Jul 02 15:44:24 2015 +0200 @@ -77,7 +77,7 @@ { const ServerIndexChange& change = dynamic_cast(*obj.get()); - boost::mutex::scoped_lock lock(that->listenersMutex_); + boost::recursive_mutex::scoped_lock lock(that->listenersMutex_); for (ServerListeners::iterator it = that->listeners_.begin(); it != that->listeners_.end(); ++it) { @@ -180,7 +180,7 @@ bool accepted = true; { - boost::mutex::scoped_lock lock(listenersMutex_); + boost::recursive_mutex::scoped_lock lock(listenersMutex_); for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { @@ -266,7 +266,7 @@ if (status == StoreStatus_Success || status == StoreStatus_AlreadyStored) { - boost::mutex::scoped_lock lock(listenersMutex_); + boost::recursive_mutex::scoped_lock lock(listenersMutex_); for (ServerListeners::iterator it = listeners_.begin(); it != listeners_.end(); ++it) { @@ -439,7 +439,7 @@ plugins_ = &plugins; // TODO REFACTOR THIS - boost::mutex::scoped_lock lock(listenersMutex_); + boost::recursive_mutex::scoped_lock lock(listenersMutex_); listeners_.clear(); listeners_.push_back(ServerListener(lua_, "Lua")); listeners_.push_back(ServerListener(plugins, "plugin")); @@ -451,7 +451,7 @@ plugins_ = NULL; // TODO REFACTOR THIS - boost::mutex::scoped_lock lock(listenersMutex_); + boost::recursive_mutex::scoped_lock lock(listenersMutex_); listeners_.clear(); listeners_.push_back(ServerListener(lua_, "Lua")); } diff -r a68545767975 -r 68827c07e683 OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Thu Jul 02 15:17:19 2015 +0200 +++ b/OrthancServer/ServerContext.h Thu Jul 02 15:44:24 2015 +0200 @@ -120,7 +120,7 @@ LuaScripting lua_; OrthancPlugins* plugins_; ServerListeners listeners_; - boost::mutex listenersMutex_; + boost::recursive_mutex listenersMutex_; bool done_; SharedMessageQueue pendingChanges_;