From: Christopher Faulet Date: Wed, 14 Dec 2022 09:26:25 +0000 (+0100) Subject: BUG/MEDIUM: resolvers: Use tick_first() to update the resolvers task timeout X-Git-Tag: v2.8-dev1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=819d48b14e7edcebc737e5fc7d4f1b269c07bc5d;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: resolvers: Use tick_first() to update the resolvers task timeout In resolv_update_resolvers_timeout(), the resolvers task timeout is updated by checking running and waiting resolutions. However, to find the next wakeup date, MIN() operator is used to compare ticks. Ticks must never be compared with such operators, tick helper functions must be used, to properly handled TICK_ETERNITY value. In this case, tick_first() must be used instead of MIN(). It is an old bug but it is pretty visible since the commit fdecaf6ae4 ("BUG/MINOR: resolvers: do not run the timeout task when there's no resolution"). Because of this bug, the resolvers task timeout may be set to TICK_ETERNITY, stopping periodic resolutions. This patch should solve the issue #1962. It must be backported to all stable versions. --- diff --git a/src/resolvers.c b/src/resolvers.c index 6696e51a36..e415c6a611 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -291,11 +291,11 @@ static void resolv_update_resolvers_timeout(struct resolvers *resolvers) if (!LIST_ISEMPTY(&resolvers->resolutions.curr)) { res = LIST_NEXT(&resolvers->resolutions.curr, struct resolv_resolution *, list); next = tick_add(now_ms, resolvers->timeout.resolve); - next = MIN(next, tick_add(res->last_query, resolvers->timeout.retry)); + next = tick_first(next, tick_add(res->last_query, resolvers->timeout.retry)); } list_for_each_entry(res, &resolvers->resolutions.wait, list) - next = MIN(next, tick_add(res->last_resolution, resolv_resolution_timeout(res))); + next = tick_first(next, tick_add(res->last_resolution, resolv_resolution_timeout(res))); resolvers->t->expire = next; task_queue(resolvers->t);