Revert any lua change

This commit is contained in:
brenosilva 2012-02-08 18:11:45 +00:00
parent 24ac0c4a9f
commit 4bebeb6dd7
2 changed files with 11 additions and 19 deletions

View File

@ -108,7 +108,9 @@ char *lua_compile(msc_script **script, const char *filename, apr_pool_t *pool) {
(*script) = apr_pcalloc(pool, sizeof(msc_script)); (*script) = apr_pcalloc(pool, sizeof(msc_script));
(*script)->name = filename; (*script)->name = filename;
(*script)->parts = dump.parts; (*script)->parts = dump.parts;
(*script)->Lstate = L;
/* Destroy state. */
lua_close(L);
return NULL; return NULL;
} }
@ -390,8 +392,8 @@ static const struct luaL_Reg mylib[] = {
*/ */
int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rule, char **error_msg) { int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rule, char **error_msg) {
apr_time_t time_before; apr_time_t time_before;
lua_State *L = script->Lstate; lua_State *L = NULL;
int rc, lvm; int rc;
if (error_msg == NULL) return -1; if (error_msg == NULL) return -1;
*error_msg = NULL; *error_msg = NULL;
@ -402,16 +404,10 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
time_before = apr_time_now(); time_before = apr_time_now();
if (L == NULL) { /* Create new state. */
/* Create new state. */ L = lua_open();
L = lua_open();
luaL_openlibs(L); luaL_openlibs(L);
lvm = 1;
if (L == NULL) {
*error_msg = apr_psprintf(msr->mp, "Lua: Failed to create Lua state");
return -1;
}
}
/* Associate msr with the state. */ /* Associate msr with the state. */
lua_pushlightuserdata(L, (void *)msr); lua_pushlightuserdata(L, (void *)msr);
@ -454,12 +450,9 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
*error_msg = apr_pstrdup(msr->mp, *error_msg); *error_msg = apr_pstrdup(msr->mp, *error_msg);
} }
lua_pop(L, 1);
/* Destroy state. */ /* Destroy state. */
if(lvm) { lua_pop(L, 1);
lua_close(L); lua_close(L);
}
/* Returns status code to caller. */ /* Returns status code to caller. */
if (msr->txcfg->debuglog_level >= 8) { if (msr->txcfg->debuglog_level >= 8) {

View File

@ -31,7 +31,6 @@ typedef struct msc_script_part msc_script_part;
struct msc_script { struct msc_script {
const char *name; const char *name;
apr_array_header_t *parts; apr_array_header_t *parts;
lua_State *Lstate;
}; };
struct msc_script_part { struct msc_script_part {