]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: resolvers: don't close the nameserver socket twice on deinit
authorMartin Mirchev <mmirchev@comp.nus.edu.sg>
Tue, 27 Oct 2026 06:29:44 +0000 (14:29 +0800)
committerWilly Tarreau <w@1wt.eu>
Wed, 28 Oct 2026 10:38:26 +0000 (11:38 +0100)
resolvers_destroy() calls fd_delete() on the UDP socket of each nameserver,
which already closes it, then calls close() on the same FD again. This
second close() fails with EBADF (visible with strace on soft-stop), and
could close an unrelated FD if the number were reused in between. Let's
just drop the redundant close().

This came with resolvers_destroy() in 2.7 (commit e606c84fe "MINOR:
resolvers: resolvers_destroy() deinit and free a resolver"). There is no
need to backport it, though it does not hurt.

src/resolvers.c

index 66006b663afb49c89a5f3c6002e3fccef2b7d107..8b78ee34117c17870a5c3bb7af5942776685811d 100644 (file)
@@ -2765,7 +2765,6 @@ static void resolvers_destroy(struct resolvers *resolvers)
                             (resolvers->t &&
                              ha_thread_info[resolvers->t->tid].tgid == tgid))) {
                                fd_delete(ns->dgram->conn.t.sock.fd);
-                               close(ns->dgram->conn.t.sock.fd);
                        }
                        dns_ring_free(ns->dgram->ring_req);
                        free(ns->dgram);