diff OrthancServer/OrthancFindRequestHandler.cpp @ 2617:912a767911b0 jobs

back to a single Lua context
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 May 2018 12:45:34 +0200
parents 2f3007bf0708
children d4fd4614f275
line wrap: on
line diff
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Tue May 22 12:25:37 2018 +0200
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Tue May 22 12:45:34 2018 +0200
@@ -47,25 +47,6 @@
 
 namespace Orthanc
 {
-  static LuaScripting& GetLuaScripting(ServerContext& context)
-  {
-    // Returns a singleton Lua context
-    static boost::mutex mutex_;
-    static std::auto_ptr<LuaScripting>  lua_;
-    
-    boost::mutex::scoped_lock lock(mutex_);
-
-    if (lua_.get() == NULL)
-    {
-      LOG(INFO) << "Initializing Lua for OrthancFindRequestHandler";
-      lua_.reset(new LuaScripting(context));
-      lua_->LoadGlobalConfiguration();
-    }
-
-    return *lua_;
-  }
-
-
   static void GetChildren(std::list<std::string>& target,
                           ServerIndex& index,
                           const std::list<std::string>& source)
@@ -505,7 +486,8 @@
   {
     static const char* LUA_CALLBACK = "IncomingFindRequestFilter";
     
-    LuaScripting::Lock lock(GetLuaScripting(context_));
+    LuaScripting::Lock lock(context_.GetLuaScripting());
+
     if (!lock.GetLua().IsExistingFunction(LUA_CALLBACK))
     {
       return false;