comparison OrthancServer/main.cpp @ 996:cf52f3bcb2b3 lua-scripting

clarification of Lua classes wrt multithreading
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 03 Jul 2014 16:27:16 +0200
parents 83489fddd8c5
children 84b6d7bca6db
comparison
equal deleted inserted replaced
995:8c67382f44a7 996:cf52f3bcb2b3
184 const char* ip, 184 const char* ip,
185 const char* username) const 185 const char* username) const
186 { 186 {
187 static const char* HTTP_FILTER = "IncomingHttpRequestFilter"; 187 static const char* HTTP_FILTER = "IncomingHttpRequestFilter";
188 188
189 ServerContext::LuaContextLocker locker(context_);
190
189 // Test if the instance must be filtered out 191 // Test if the instance must be filtered out
190 if (context_.GetLuaContext().IsExistingFunction(HTTP_FILTER)) 192 if (locker.GetLua().IsExistingFunction(HTTP_FILTER))
191 { 193 {
192 LuaFunctionCall call(context_.GetLuaContext(), HTTP_FILTER); 194 LuaFunctionCall call(locker.GetLua(), HTTP_FILTER);
193 195
194 switch (method) 196 switch (method)
195 { 197 {
196 case HttpMethod_Get: 198 case HttpMethod_Get:
197 call.PushString("GET"); 199 call.PushString("GET");
369 { 371 {
370 std::string path = Configuration::InterpretStringParameterAsPath(*it); 372 std::string path = Configuration::InterpretStringParameterAsPath(*it);
371 LOG(WARNING) << "Installing the Lua scripts from: " << path; 373 LOG(WARNING) << "Installing the Lua scripts from: " << path;
372 std::string script; 374 std::string script;
373 Toolbox::ReadFile(script, path); 375 Toolbox::ReadFile(script, path);
374 context.GetLuaContext().Execute(script); 376
377 ServerContext::LuaContextLocker locker(context);
378 locker.GetLua().Execute(script);
375 } 379 }
376 380
377 381
378 try 382 try
379 { 383 {