diff --git a/userspace/engine/falco_common.h b/userspace/engine/falco_common.h index f304b6e5..64659186 100644 --- a/userspace/engine/falco_common.h +++ b/userspace/engine/falco_common.h @@ -21,6 +21,7 @@ limitations under the License. #include #include +#include extern "C" { #include "lua.h" @@ -94,11 +95,10 @@ public: protected: lua_State *m_ls; + std::mutex m_ls_semaphore; + sinsp *m_inspector; private: void add_lua_path(std::string &path); -}; - - - +}; \ No newline at end of file diff --git a/userspace/engine/falco_engine.cpp b/userspace/engine/falco_engine.cpp index e3e8327b..98971be6 100644 --- a/userspace/engine/falco_engine.cpp +++ b/userspace/engine/falco_engine.cpp @@ -287,8 +287,8 @@ unique_ptr falco_engine::process_sinsp_event(sinsp_ev unique_ptr res(new rule_result()); + std::lock_guard guard(m_ls_semaphore); lua_getglobal(m_ls, lua_on_event.c_str()); - if(lua_isfunction(m_ls, -1)) { lua_pushnumber(m_ls, ev->get_check_id()); @@ -335,8 +335,8 @@ unique_ptr falco_engine::process_k8s_audit_event(json unique_ptr res(new rule_result()); + std::lock_guard guard(m_ls_semaphore); lua_getglobal(m_ls, lua_on_event.c_str()); - if(lua_isfunction(m_ls, -1)) { lua_pushnumber(m_ls, ev->get_check_id());