diff --git a/CHANGES b/CHANGES index b103825c3c..9c6cc7aa6e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + 237. [bug] If connect() returned ENOBUFS when the resolver was + initiating a TCP query, the socket didn't get destroyed, + and the server did not shut down cleanly. + 236. [func] Added new listen-on-v6 config file statement. 235. [func] Consider it a config file error if a listen-on diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index adb06a9671..9275f84c56 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -684,10 +684,8 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, INSIST(0); } result = isc_socket_bind(query->tcpsocket, &any); - if (result != ISC_R_SUCCESS) { - isc_socket_detach(&query->tcpsocket); - goto cleanup_query; - } + if (result != ISC_R_SUCCESS) + goto cleanup_socket; /* * A dispatch will be created once the connect succeeds. @@ -730,7 +728,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, &addrinfo->sockaddr, task, resquery_connected, query); if (result != ISC_R_SUCCESS) - goto cleanup_query; + goto cleanup_socket; query->attributes |= RESQUERY_ATTR_CONNECTING; QTRACE("connecting via TCP"); } else { @@ -743,8 +741,12 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, return (ISC_R_SUCCESS); + cleanup_socket: + isc_socket_detach(&query->tcpsocket); + cleanup_dispatch: - dns_dispatch_detach(&query->dispatch); + if (query->dispatch != NULL) + dns_dispatch_detach(&query->dispatch); cleanup_query: query->magic = 0;