]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: lua: use task_wakeup() to properly run a task once
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Sep 2021 14:17:37 +0000 (16:17 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Sep 2021 14:26:51 +0000 (16:26 +0200)
The Lua tasks registered vi core.register_task() use a dangerous
task_schedule(task, now_ms) to start them, that will most of the
time work by accident, except when the time wraps every 49.7 days,
if now_ms is 0, because it's not valid to queue a task with an
expiration date set to TICK_ETERNITY, as it will fail all wakeup
checks and prevent all subsequent timers from being seen as expired.
The only solution in this case is to restart the process.

Fortunately for the vast majority of users it is extremely unlikely
to ever be met (only one millisecond every 49.7 days is at risk), but
this can be systematic for a process dealing with 1000 req/s, hence
the major tag.

The bug was introduced in 1.6-dev with commit 24f335340 ("MEDIUM: lua:
add coroutine as tasks."), so the fix must be backported to all stable
branches.

src/hlua.c

index 02dffe7d75298e2b000fca39a976eb7edcaa53f0..df463492b4b49b388cc11de94f35996ca5773b85 100644 (file)
@@ -8268,7 +8268,7 @@ static int hlua_register_task(lua_State *L)
        hlua->nargs = 0;
 
        /* Schedule task. */
-       task_schedule(task, now_ms);
+       task_wakeup(task, TASK_WOKEN_INIT);
 
        return 0;