]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
run read callbacks synchronously on timeout
authorEvan Hunt <each@isc.org>
Wed, 21 Apr 2021 06:27:51 +0000 (23:27 -0700)
committerEvan Hunt <each@isc.org>
Thu, 22 Apr 2021 19:08:04 +0000 (12:08 -0700)
when running read callbacks, if the event result is not ISC_R_SUCCESS,
the callback is always run asynchronously. this is a problem on timeout,
because there's no chance to reset the timer before the socket has
already been destroyed. this commit allows read callbacks to run
synchronously for both ISC_R_SUCCESS and ISC_R_TIMEDOUT result codes.

lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tcp.c
lib/isc/netmgr/tcpdns.c
lib/isc/netmgr/tlsdns.c
lib/isc/netmgr/udp.c

index c2891f1a637fd6fe4c7e6173fa863e31b2fb76f4..5052bd00f6ec47f63a04dd6fe971c1c9d6cc4dc2 100644 (file)
@@ -2550,7 +2550,7 @@ isc__nm_readcb(isc_nmsocket_t *sock, isc__nm_uvreq_t *uvreq,
        REQUIRE(VALID_UVREQ(uvreq));
        REQUIRE(VALID_NMHANDLE(uvreq->handle));
 
-       if (eresult == ISC_R_SUCCESS) {
+       if (eresult == ISC_R_SUCCESS || eresult == ISC_R_TIMEDOUT) {
                isc__netievent_readcb_t ievent = { .sock = sock,
                                                   .req = uvreq,
                                                   .result = eresult };
index d86e1866e5e41843aac249cf233a26b6e9233ebe..f950ba2646036613c3f862ba03d6675e99d4179e 100644 (file)
@@ -676,9 +676,11 @@ failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
 destroy:
        isc__nmsocket_prep_destroy(sock);
 
-       /* We need to detach from quota after the read callback function had a
-        * chance to be executed. */
-       if (sock->quota) {
+       /*
+        * We need to detach from quota after the read callback function had a
+        * chance to be executed.
+        */
+       if (sock->quota != NULL) {
                isc_quota_detach(&sock->quota);
        }
 }
index f8005bb4d9434610f0a4f906657803cac0ed1950..9d2601b90696ea760be7b244581eaeafd2729332 100644 (file)
@@ -651,9 +651,11 @@ isc__nm_tcpdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
 destroy:
        isc__nmsocket_prep_destroy(sock);
 
-       /* We need to detach from quota after the read callback function had a
-        * chance to be executed. */
-       if (sock->quota) {
+       /*
+        * We need to detach from quota after the read callback function had a
+        * chance to be executed.
+        */
+       if (sock->quota != NULL) {
                isc_quota_detach(&sock->quota);
        }
 }
index ff83fa4624383b5504fe8d713b4f82a6b7708719..bb7ea76a3c25f3b49fb68311f2e1f1c019d11e31 100644 (file)
@@ -802,9 +802,11 @@ isc__nm_tlsdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
 destroy:
        isc__nmsocket_prep_destroy(sock);
 
-       /* We need to detach from quota after the read callback function
-        * had a chance to be executed. */
-       if (sock->quota) {
+       /*
+        * We need to detach from quota after the read callback function
+        * had a chance to be executed.
+        */
+       if (sock->quota != NULL) {
                isc_quota_detach(&sock->quota);
        }
 }
index eb57c954be2ac0f855d41a7afe36c017003d934d..ef404d93da9a4150f7f380aa20c9eb7f5ab81d5d 100644 (file)
@@ -815,6 +815,7 @@ isc__nm_udp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) {
        REQUIRE(result != ISC_R_SUCCESS);
 
        if (atomic_load(&sock->client)) {
+               isc__nmsocket_timer_stop(sock);
                isc__nm_stop_reading(sock);
 
                if (!sock->recv_read) {