From: Evan Hunt Date: Wed, 21 Apr 2021 06:27:51 +0000 (-0700) Subject: run read callbacks synchronously on timeout X-Git-Tag: v9.17.13~45^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bcf5b2a67523bf0f6c1394d241c3d92128137373;p=thirdparty%2Fbind9.git run read callbacks synchronously on timeout 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. --- diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index c2891f1a637..5052bd00f6e 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -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 }; diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index d86e1866e5e..f950ba26460 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -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); } } diff --git a/lib/isc/netmgr/tcpdns.c b/lib/isc/netmgr/tcpdns.c index f8005bb4d94..9d2601b9069 100644 --- a/lib/isc/netmgr/tcpdns.c +++ b/lib/isc/netmgr/tcpdns.c @@ -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); } } diff --git a/lib/isc/netmgr/tlsdns.c b/lib/isc/netmgr/tlsdns.c index ff83fa46243..bb7ea76a3c2 100644 --- a/lib/isc/netmgr/tlsdns.c +++ b/lib/isc/netmgr/tlsdns.c @@ -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); } } diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index eb57c954be2..ef404d93da9 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -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) {