From: Remi Gacogne Date: Tue, 16 Feb 2016 08:44:51 +0000 (+0100) Subject: dnsdist: Lock the Lua context before executing a LuaAction X-Git-Tag: auth-4.0.0-alpha2~50^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3388%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Lock the Lua context before executing a LuaAction Otherwise the stack of the Lua context might get corrupted whenever another Lua function (blockfilter, policy, maintenance or another LuaAction) is simultaneously called from another thread. We might be able to use a separate execution stack via createThread()/lua_newthread(), but if I understand correctly how it works, we would need to be sure that the Lua function called does not access the global state at all, which is probably too restrictive. This should fix #3374, #3375, #3376, #3377, #3378, #3379, #3383, and hopefully the random travis failures in our regression tests. --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index d83f586647..32fc832821 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -22,6 +22,7 @@ public: Action operator()(DNSQuestion* dq, string* ruleresult) const override { + std::lock_guard lock(g_luamutex); auto ret = d_func(dq); if(ruleresult) *ruleresult=std::get<1>(ret);