Skip to content

Commit

Permalink
fix(userspace/engine): guard lua state into falco engine
Browse files Browse the repository at this point in the history
Co-authored-by: Lorenzo Fontana <lo@linux.com>
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
  • Loading branch information
leodido and fntlnz committed Sep 30, 2019
1 parent f0cd334 commit 8a6c0b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions userspace/engine/falco_common.h
Expand Up @@ -21,6 +21,7 @@ limitations under the License.

#include <string>
#include <exception>
#include <mutex>

extern "C" {
#include "lua.h"
Expand Down Expand Up @@ -94,11 +95,10 @@ class falco_common
protected:
lua_State *m_ls;

std::mutex m_ls_semaphore;

sinsp *m_inspector;

private:
void add_lua_path(std::string &path);
};



};
4 changes: 2 additions & 2 deletions userspace/engine/falco_engine.cpp
Expand Up @@ -287,8 +287,8 @@ unique_ptr<falco_engine::rule_result> falco_engine::process_sinsp_event(sinsp_ev

unique_ptr<struct rule_result> res(new rule_result());

std::lock_guard<std::mutex> 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());
Expand Down Expand Up @@ -335,8 +335,8 @@ unique_ptr<falco_engine::rule_result> falco_engine::process_k8s_audit_event(json

unique_ptr<struct rule_result> res(new rule_result());

std::lock_guard<std::mutex> 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());
Expand Down

0 comments on commit 8a6c0b7

Please sign in to comment.