detect/lua: add thread_init

Add optional `thread_init` function support. This function is called per
script, per thread to allow a user to initialize the lua state.
pull/12379/head
Victor Julien 2 years ago committed by Victor Julien
parent c3e61e07f0
commit e89ab4f88a

@ -523,6 +523,18 @@ static void *DetectLuaThreadInit(void *data)
goto error;
}
/* thread_init call */
lua_getglobal(t->luastate, "thread_init");
if (lua_isfunction(t->luastate, -1)) {
if (lua_pcall(t->luastate, 0, 0, 0) != 0) {
SCLogError("couldn't run script 'thread_init' function: %s",
lua_tostring(t->luastate, -1));
goto error;
}
} else {
lua_pop(t->luastate, 1);
}
return (void *)t;
error:

Loading…
Cancel
Save