diff --git a/include/haproxy/hlua-t.h b/include/haproxy/hlua-t.h index 2672ffdcf..af54d8694 100644 --- a/include/haproxy/hlua-t.h +++ b/include/haproxy/hlua-t.h @@ -67,6 +67,7 @@ struct stream; #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 diff --git a/include/haproxy/hlua.h b/include/haproxy/hlua.h index 3c67ccea8..18fad9ff2 100644 --- a/include/haproxy/hlua.h +++ b/include/haproxy/hlua.h @@ -30,6 +30,9 @@ #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) diff --git a/src/debug.c b/src/debug.c index d1526e1d4..ff5480373 100644 --- a/src/debug.c +++ b/src/debug.c @@ -302,7 +302,7 @@ void ha_thread_dump_one(int thr, int from_signal) 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); @@ -417,7 +417,8 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx) #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)) { diff --git a/src/hlua.c b/src/hlua.c index 7f1dfed6d..e0a5bfdff 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1803,6 +1803,8 @@ resume_execution: /* 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); @@ -1810,6 +1812,8 @@ resume_execution: 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);