From: Willy Tarreau Date: Wed, 17 Feb 2021 14:15:15 +0000 (+0100) Subject: BUG/MINOR: checks: properly handle wrapping time in __health_adjust() X-Git-Tag: v2.1.12~38 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=b14aa5943098cc3c21c01379f1fca12f3fb111bf;p=haproxy-2.1.git BUG/MINOR: checks: properly handle wrapping time in __health_adjust() There's an issue when a server state changes, we use an integer comparison to decide whether or not to reschedule a test instead of using a wrapping timer comparison. This will cause some health-checks not to be immediately triggered half of the time, and some unneeded calls to task_queue() to be performed in other cases. This bug has always been there as it was introduced with the commit that added the feature, 97f07b832 ("[MEDIUM] Decrease server health based on http responses / events, version 3"). This may be backported everywhere. (cherry picked from commit 64ba5ebadcd5d98e00989d08dfaa3c94c15196c9) Signed-off-by: Christopher Faulet (cherry picked from commit 4d45917e6e57c29e9cc7f1a3cb05f6e4212ee842) Signed-off-by: Christopher Faulet (cherry picked from commit 2e432f3a44a6730472732a56f78ed0c7bbb40684) Signed-off-by: Christopher Faulet --- diff --git a/src/checks.c b/src/checks.c index 78a92d0..adc941a 100644 --- a/src/checks.c +++ b/src/checks.c @@ -473,7 +473,7 @@ void __health_adjust(struct server *s, short status) if (s->check.fastinter) { expire = tick_add(now_ms, MS_TO_TICKS(s->check.fastinter)); - if (s->check.task->expire > expire) { + if (tick_is_lt(expire, s->check.task->expire)) { s->check.task->expire = expire; /* requeue check task with new expire */ task_queue(s->check.task);