]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Call the isc__nm_failed_connect_cb() early when shutting down
authorOndřej Surý <ondrej@sury.org>
Thu, 18 Mar 2021 20:37:12 +0000 (21:37 +0100)
committerEvan Hunt <each@isc.org>
Thu, 18 Mar 2021 21:31:15 +0000 (14:31 -0700)
When shutting down, calling the isc__nm_failed_connect_cb() was delayed
until the connect callback would be called.  It turned out that the
connect callback might not get called at all when the socket is being
shut down.  Call the failed_connect_cb() directly in the
tlsdns_shutdown() instead of waiting for the connect callback to call it.

lib/isc/netmgr/tlsdns.c

index 961dceaadd514bb207cce561ef7864e256826fcd..330a2ae324ea3acca0f22f8f4e2adb58c187d536 100644 (file)
@@ -760,7 +760,7 @@ isc__nm_tlsdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
        isc__nmsocket_timer_stop(sock);
        isc__nm_stop_reading(sock);
 
-       if (sock->tls.pending_req) {
+       if (sock->tls.pending_req != NULL) {
                isc__nm_uvreq_t *req = sock->tls.pending_req;
                sock->tls.pending_req = NULL;
                isc__nm_failed_connect_cb(sock, req, ISC_R_CANCELED);
@@ -1835,16 +1835,16 @@ isc__nm_tlsdns_shutdown(isc_nmsocket_t *sock) {
                return;
        }
 
-       if (atomic_load(&sock->connecting) || sock->accepting) {
-               return;
-       }
-
-       if (sock->tls.pending_req) {
+       if (sock->tls.pending_req != NULL) {
                isc__nm_uvreq_t *req = sock->tls.pending_req;
                sock->tls.pending_req = NULL;
                isc__nm_failed_connect_cb(sock, req, ISC_R_CANCELED);
        }
 
+       if (atomic_load(&sock->connecting) || sock->accepting) {
+               return;
+       }
+
        if (sock->statichandle) {
                isc__nm_failed_read_cb(sock, ISC_R_CANCELED);
                return;