#define HLUA_WAKEREQWR 0x00000008
#define HLUA_EXIT 0x00000010
#define HLUA_NOYIELD 0x00000020
+#define HLUA_BUSY 0x00000040
#define HLUA_F_AS_STRING 0x01
#define HLUA_F_MAY_USE_HTTP 0x02
#define HLUA_SET_RUN(__hlua) do {(__hlua)->flags |= HLUA_RUN;} while(0)
#define HLUA_CLR_RUN(__hlua) do {(__hlua)->flags &= ~HLUA_RUN;} while(0)
#define HLUA_IS_RUNNING(__hlua) ((__hlua)->flags & HLUA_RUN)
+#define HLUA_SET_BUSY(__hlua) do {(__hlua)->flags |= HLUA_BUSY;} while(0)
+#define HLUA_CLR_BUSY(__hlua) do {(__hlua)->flags &= ~HLUA_BUSY;} while(0)
+#define HLUA_IS_BUSY(__hlua) ((__hlua)->flags & HLUA_BUSY)
#define HLUA_SET_CTRLYIELD(__hlua) do {(__hlua)->flags |= HLUA_CTRLYIELD;} while(0)
#define HLUA_CLR_CTRLYIELD(__hlua) do {(__hlua)->flags &= ~HLUA_CTRLYIELD;} while(0)
#define HLUA_IS_CTRLYIELDING(__hlua) ((__hlua)->flags & HLUA_CTRLYIELD)
const struct stream *s = (const struct stream *)th_ctx->current->context;
struct hlua *hlua = s ? s->hlua : NULL;
- if (hlua && hlua->T) {
+ if (hlua && HLUA_IS_BUSY(hlua)) {
mark_tainted(TAINTED_LUA_STUCK);
if (hlua->state_id == 0)
mark_tainted(TAINTED_LUA_STUCK_SHARED);
#ifdef USE_LUA
hlua = NULL;
- if (s && (hlua = s->hlua)) {
+ if (s && s->hlua && HLUA_IS_BUSY(s->hlua)) {
+ hlua = s->hlua;
chunk_appendf(buf, "%sCurrent executing Lua from a stream analyser -- ", pfx);
}
else if (task->process == hlua_process_task && (hlua = task->context)) {
/* start the timer as we're about to start lua processing */
hlua_timer_start(&lua->timer);
+ HLUA_SET_BUSY(lua);
+
/* Call the function. */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 504
ret = lua_resume(lua->T, hlua_states[lua->state_id], lua->nargs, &nres);
ret = lua_resume(lua->T, hlua_states[lua->state_id], lua->nargs);
#endif
+ HLUA_CLR_BUSY(lua);
+
/* out of lua processing, stop the timer */
hlua_timer_stop(&lua->timer);