det_ctx->discontinue_matching = 0;
goto no_match;
-#ifdef HAVE_LUAJIT
+#ifdef HAVE_LUA
}
else if (sm->type == DETECT_LUAJIT) {
- SCLogDebug("luajit starting");
+ SCLogDebug("lua starting");
/* for flowvar gets and sets we need to know the flow's lock status */
int need_flow_lock = 0;
if (inspection_mode <= DETECT_ENGINE_CONTENT_INSPECTION_MODE_STREAM)
if (DetectLuajitMatchBuffer(det_ctx, s, sm, buffer, buffer_len,
det_ctx->buffer_offset, f, need_flow_lock) != 1)
{
- SCLogDebug("luajit no_match");
+ SCLogDebug("lua no_match");
goto no_match;
}
- SCLogDebug("luajit match");
+ SCLogDebug("lua match");
goto match;
-#endif
+#endif /* HAVE_LUA */
} else {
SCLogDebug("sm->type %u", sm->type);
#ifdef DEBUG
#include "util-cpu.h"
#include "util-var-name.h"
-#ifndef HAVE_LUAJIT
+#ifndef HAVE_LUA
static int DetectLuajitSetupNoSupport (DetectEngineCtx *a, Signature *b, char *c) {
SCLogError(SC_ERR_NO_LUAJIT_SUPPORT, "no LuaJIT support built in, needed for luajit keyword");
return;
}
-#else /* HAVE_LUAJIT */
+#else /* HAVE_LUA */
+#ifdef HAVE_LUAJIT
#include "util-pool.h"
+/** \brief lua_State pool
+ *
+ * Luajit requires states to be alloc'd in memory <2GB. For this reason we
+ * prealloc the states early during engine startup so we have a better chance
+ * of getting the states. We protect the pool with a lock as the detect
+ * threads access it during their init and cleanup.
+ *
+ * Pool size is automagically determined based on number of keyword occurences,
+ * cpus/cores and rule reloads being enabled or not.
+ *
+ * Alternatively, the "detect-engine.luajit-states" var can be set.
+ */
+static Pool *luajit_states = NULL;
+static pthread_mutex_t luajit_states_lock = SCMUTEX_INITIALIZER;
+
+#endif /* HAVE_LUAJIT */
+
static int DetectLuajitMatch (ThreadVars *, DetectEngineThreadCtx *,
Packet *, Signature *, SigMatch *);
static int DetectLuajitSetup (DetectEngineCtx *, Signature *, char *);
return;
}
-/** \brief lua_State pool
- *
- * Luajit requires states to be alloc'd in memory <2GB. For this reason we
- * prealloc the states early during engine startup so we have a better chance
- * of getting the states. We protect the pool with a lock as the detect
- * threads access it during their init and cleanup.
- *
- * Pool size is automagically determined based on number of keyword occurences,
- * cpus/cores and rule reloads being enabled or not.
- *
- * Alternatively, the "detect-engine.luajit-states" var can be set.
- */
-static Pool *luajit_states = NULL;
-static pthread_mutex_t luajit_states_lock = SCMUTEX_INITIALIZER;
-
#define DATATYPE_PACKET (1<<0)
#define DATATYPE_PAYLOAD (1<<1)
#define DATATYPE_STREAM (1<<2)
#define DATATYPE_HTTP_RESPONSE_HEADERS (1<<13)
#define DATATYPE_HTTP_RESPONSE_HEADERS_RAW (1<<14)
+#ifdef HAVE_LUAJIT
static void *LuaStatePoolAlloc(void) {
return luaL_newstate();
}
pthread_mutex_unlock(&luajit_states_lock);
return retval;
}
+#endif /* HAVE_LUAJIT */
static lua_State *DetectLuajitGetState(void) {
lua_State *s = NULL;
+#ifdef HAVE_LUAJIT
pthread_mutex_lock(&luajit_states_lock);
if (luajit_states != NULL)
s = (lua_State *)PoolGet(luajit_states);
pthread_mutex_unlock(&luajit_states_lock);
+#else
+ s = luaL_newstate();
+#endif
return s;
}
static void DetectLuajitReturnState(lua_State *s) {
if (s != NULL) {
+#ifdef HAVE_LUAJIT
pthread_mutex_lock(&luajit_states_lock);
PoolReturn(luajit_states, (void *)s);
pthread_mutex_unlock(&luajit_states_lock);
+#else
+ lua_close(s);
+#endif
}
}