]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: lua: Init the lua wake_time value before calling a lua function
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Feb 2020 13:55:16 +0000 (14:55 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Mar 2020 13:13:00 +0000 (14:13 +0100)
The wake_time of a lua context is now always set to TICK_ETERNITY when the
context is initialized and when everytime the execution of the lua stack is
started. It is mandatory to not set arbitrary wake_time when an action yields.

No backport needed.

src/hlua.c

index dda156dda681e76292f25d8c6b970c64c0f3774b..a8f48b39941cefaea2a560c89a976a67890c6651 100644 (file)
@@ -907,6 +907,7 @@ int hlua_ctx_init(struct hlua *lua, struct task *task, int already_safe)
        lua->Mref = LUA_REFNIL;
        lua->flags = 0;
        lua->gc_count = 0;
+       lua->wake_time = TICK_ETERNITY;
        LIST_INIT(&lua->com);
        lua->T = lua_newthread(gL.T);
        if (!lua->T) {
@@ -1098,8 +1099,9 @@ resume_execution:
        HLUA_CLR_WAKERESWR(lua);
        HLUA_CLR_WAKEREQWR(lua);
 
-       /* Update the start time. */
+       /* Update the start time and reset wake_time. */
        lua->start_time = now_ms;
+       lua->wake_time = TICK_ETERNITY;
 
        /* Call the function. */
        ret = lua_resume(lua->T, gL.T, lua->nargs);