]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: resolvers: do not run the timeout task when there's no resolution
authorWilly Tarreau <w@1wt.eu>
Mon, 21 Nov 2022 18:15:22 +0000 (19:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 21 Nov 2022 18:21:07 +0000 (19:21 +0100)
The function resolv_update_resolvers_timeout() always schedules a wakeup
of the process_resolvers() task based on the "timeout resolve" setting,
regardless of the presence of an ongoing resolution or not. This is causing
one wakeup every second by default even when there's no resolvers section
(due to the default one), and can even be worse: creating a section with
"timeout resolve 1" bombs the process with 1000 wakeups per second.

Let's condition the setting to the presence of a resolution to address
this.

This issue has been there forever, but it doesn't cause that much trouble,
and given how fragile and tricky this code is, it's probably wise to
refrain from backporting it until it's reported to really cause trouble.

src/resolvers.c

index 9cb23113b59479eb43e473281b9d862abb86ffc4..456b121b454621d8dff503a228c29117544f61f5 100644 (file)
@@ -286,11 +286,11 @@ static inline int resolv_resolution_timeout(struct resolv_resolution *res)
 static void resolv_update_resolvers_timeout(struct resolvers *resolvers)
 {
        struct resolv_resolution *res;
-       int next;
+       int next = TICK_ETERNITY;
 
-       next = tick_add(now_ms, resolvers->timeout.resolve);
        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));
        }