]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: debug: make sure the "debug dev sched" tasks don't block stopping
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Feb 2025 17:01:32 +0000 (18:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Feb 2025 17:04:29 +0000 (18:04 +0100)
When "debug dev sched" is used to pop up background tasks, these tasks
are never stopped, so we must be careful to stop them when the stopping
flag is set, otherwise they can prevent the process from stopping when
sufficiently numerous (tests went as far as 100 million tasks, leading
the run queue never being completely purged in one poll round).

No backport is needed since this is only used when debugging and tuning
the scheduler.

src/debug.c

index 6f8f5a964b62d910ee7907c1f717eef4371a78ae..61254ba4e3bfe8fcd978bafe864c8481ae58bc13 100644 (file)
@@ -1520,6 +1520,9 @@ static struct task *debug_task_handler(struct task *t, void *ctx, unsigned int s
        unsigned long inter = tctx[1];
        unsigned long rnd;
 
+       if (stopping)
+               return NULL;
+
        t->expire = tick_add(now_ms, inter);
 
        /* half of the calls will wake up another entry */
@@ -1543,6 +1546,9 @@ static struct task *debug_tasklet_handler(struct task *t, void *ctx, unsigned in
        unsigned long rnd;
        int i;
 
+       if (stopping)
+               return NULL;
+
        /* wake up two random entries */
        for (i = 0; i < 2; i++) {
                rnd = statistical_prng() % tctx[0];