#include <proto/arg.h>
#include <proto/channel.h>
#include <proto/hdr_idx.h>
+#include <proto/hlua.h>
#include <proto/obj_type.h>
#include <proto/pattern.h>
#include <proto/payload.h>
int hlua_ctx_init(struct hlua *lua, struct task *task)
{
lua->Mref = LUA_REFNIL;
- lua->state = HLUA_STOP;
+ lua->flags = 0;
LIST_INIT(&lua->com);
lua->T = lua_newthread(gL.T);
if (!lua->T) {
int ret;
const char *msg;
- lua->state = HLUA_RUN;
+ HLUA_SET_RUN(lua);
/* Call the function. */
ret = lua_resume(lua->T, gL.T, lua->nargs);
case HLUA_E_ERRMSG:
hlua_com_purge(lua);
hlua_ctx_renew(lua, 1);
- lua->state = HLUA_STOP;
+ HLUA_CLR_RUN(lua);
break;
case HLUA_E_ERR:
- lua->state = HLUA_STOP;
+ HLUA_CLR_RUN(lua);
hlua_com_purge(lua);
hlua_ctx_renew(lua, 0);
break;
case HLUA_E_OK:
- lua->state = HLUA_STOP;
+ HLUA_CLR_RUN(lua);
hlua_com_purge(lua);
break;
}
socket->s->hlua.Tref = LUA_REFNIL;
socket->s->hlua.Mref = LUA_REFNIL;
socket->s->hlua.nargs = 0;
- socket->s->hlua.state = HLUA_STOP;
+ socket->s->hlua.flags = 0;
LIST_INIT(&socket->s->hlua.com);
/* session initialisation. */
}
/* If it is the first run, initialize the data for the call. */
- if (session->hlua.state == HLUA_STOP) {
+ if (!HLUA_IS_RUNNING(&session->hlua)) {
/* Check stack available size. */
if (!lua_checkstack(session->hlua.T, 1)) {
send_log(session->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
}
/* Set the currently running flag. */
- session->hlua.state = HLUA_RUN;
+ HLUA_SET_RUN(&session->hlua);
}
/* Execute the function. */
}
/* If it is the first run, initialize the data for the call. */
- if (s->hlua.state == HLUA_STOP) {
+ if (!HLUA_IS_RUNNING(&s->hlua)) {
/* Check stack available size. */
if (!lua_checkstack(s->hlua.T, 2)) {
send_log(px, LOG_ERR, "Lua sample-fetch '%s': full stack.", fcn->name);
}
/* Set the currently running flag. */
- s->hlua.state = HLUA_RUN;
+ HLUA_SET_RUN(&s->hlua);
}
/* Execute the function. */
}
/* If it is the first run, initialize the data for the call. */
- if (s->hlua.state == HLUA_STOP) {
+ if (!HLUA_IS_RUNNING(&s->hlua)) {
/* Check stack available size. */
if (!lua_checkstack(s->hlua.T, 1)) {
send_log(px, LOG_ERR, "Lua function '%s': full stack.", rule->fcn.name);
}
/* Set the currently running flag. */
- s->hlua.state = HLUA_RUN;
+ HLUA_SET_RUN(&s->hlua);
}
/* Execute the function. */
/* Init main lua stack. */
gL.Mref = LUA_REFNIL;
- gL.state = HLUA_STOP;
+ gL.flags = 0;
LIST_INIT(&gL.com);
gL.T = luaL_newstate();
hlua_sethlua(&gL);