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)
committerWilly Tarreau <w@1wt.eu>
Thu, 30 Sep 2021 15:09:39 +0000 (17:09 +0200)
commit7a9699916a92a98ca5daaff77e2a25f9bec8817d
tree1768bc291fcbc8600f45a9c17891d30f40c8e91b
parentcb59e0bc3cbe48eedd88e91b999a471724a6b709
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.
include/haproxy/task.h
src/task.c