From fdecaf6ae49b9fef923cba7c3f20d395ed6d72f2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 21 Nov 2022 19:15:22 +0100 Subject: [PATCH] BUG/MINOR: resolvers: do not run the timeout task when there's no resolution 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resolvers.c b/src/resolvers.c index 9cb23113b5..456b121b45 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -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)); } -- 2.39.5