MINOR: tasks: catch TICK_ETERNITY with BUG_ON() in __task_queue()
authorWilly Tarreau <w@1wt.eu>
Thu, 30 Sep 2021 14:38:09 +0000 (16:38 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 4 Oct 2021 16:11:39 +0000 (18:11 +0200)
commit0cbcab32a0815c8640e4239dac1922eaf2189de2
tree55c28543c04b897bfa310007939da03ba3072ea1
parent36d0628d66a3e73ed8d6de069d8e1b459ed6a761
MINOR: tasks: catch TICK_ETERNITY with BUG_ON() in __task_queue()

__task_queue() must absolutely not be called with TICK_ETERNITY or it
will place a never-expiring node upfront in the timers queue, preventing
any timer from expiring until the process is restarted. Code was found
to cause this using "task_schedule(task, now_ms)" which does this one
millisecond every 49.7 days, so let's add a condition against this. It
must never trigger since any process susceptible to trigger it would
already accumulate tasks until it dies.

An extra test was added in wake_expired_tasks() to detect tasks whose
timeout would have been changed after being queued.

An improvement over this could be in the future to use a non-scalar
type (union/struct) for expiration dates so as to avoid the risk of
using them directly like this. But now_ms is already such a valid
time and this specific construct would still not be caught.

This could even be backported to stable versions to help detect other
occurrences if any.

(cherry picked from commit 7a9699916a92a98ca5daaff77e2a25f9bec8817d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit aaed609f9189915ef610cc47d8d1930ebb257b9d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
include/haproxy/task.h
src/task.c