]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: resolvers: Wakeup DNS idle task on stopping
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Apr 2023 05:58:27 +0000 (07:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Apr 2023 06:19:06 +0000 (08:19 +0200)
Thanks to previous commit ("BUG/MEDIUM: dns: Kill idle DNS sessions during
stopping stage"), DNS idle sessions are killed on stopping staged. But the
task responsible to kill these sessions is running every 5 seconds. It
means, when HAProxy is stopped, we can observe a delay before the process
exits.

To reduce this delay, when the resolvers task is executed, all DNS idle
tasks are woken up.

This patch must be backported as far as 2.6.

src/resolvers.c

index 0b78fafb8b5374cd8dd2898ab38fd5de6cb37e07..632d906113586a57f31b1b47319f9a4742b58ae2 100644 (file)
@@ -2451,9 +2451,19 @@ struct task *process_resolvers(struct task *t, void *context, unsigned int state
                        LIST_APPEND(&resolvers->resolutions.wait, &res->list);
                }
        }
+
        resolv_update_resolvers_timeout(resolvers);
        HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock);
 
+       if (unlikely(stopping)) {
+               struct dns_nameserver *ns;
+
+               list_for_each_entry(ns, &resolvers->nameservers, list) {
+                       if (ns->stream)
+                               task_wakeup(ns->stream->task_idle, TASK_WOKEN_MSG);
+               }
+       }
+
        /* now we can purge all queued deletions */
        leave_resolver_code();
        return t;