]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: checks: properly handle wrapping time in __health_adjust()
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Feb 2021 14:15:15 +0000 (15:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Feb 2021 09:06:45 +0000 (10:06 +0100)
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.

src/check.c

index d17f747fe1ad24c49b7583fe426d36b3f9d1df2d..06c86af799148e85fbf2210b2c8433a5cd9515bc 100644 (file)
@@ -481,7 +481,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);