From c90da99180b2c62cd1b31271b62b2d31a7e70fd9 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 21 Apr 2021 10:27:46 -0700 Subject: [PATCH] fix TCP timeout recovery removed an unnecessary assert in the failed_read_cb() function. also renamed to isc__nm_tcp_failed_read_cb() to match the practice in other modules. --- lib/isc/netmgr/tcp.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index f950ba2646..80ce1193c2 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -654,10 +654,10 @@ isc__nm_async_tcpstop(isc__networker_t *worker, isc__netievent_t *ev0) { stop_tcp_parent(sock); } -static void -failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) { +void +isc__nm_tcp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) { REQUIRE(VALID_NMSOCK(sock)); - REQUIRE(sock->statichandle != NULL); + REQUIRE(result != ISC_R_SUCCESS); isc__nmsocket_timer_stop(sock); isc__nm_stop_reading(sock); @@ -685,11 +685,6 @@ destroy: } } -void -isc__nm_tcp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result) { - failed_read_cb(sock, result); -} - static void failed_send_cb(isc_nmsocket_t *sock, isc__nm_uvreq_t *req, isc_result_t eresult) { @@ -752,7 +747,7 @@ isc__nm_async_tcpstartread(isc__networker_t *worker, isc__netievent_t *ev0) { if (isc__nmsocket_closing(sock)) { sock->reading = true; - failed_read_cb(sock, ISC_R_CANCELED); + isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED); return; } @@ -762,11 +757,12 @@ isc__nm_async_tcpstartread(isc__networker_t *worker, isc__netievent_t *ev0) { void isc__nm_tcp_pauseread(isc_nmhandle_t *handle) { - REQUIRE(VALID_NMHANDLE(handle)); - REQUIRE(VALID_NMSOCK(handle->sock)); - isc__netievent_tcppauseread_t *ievent = NULL; - isc_nmsocket_t *sock = handle->sock; + isc_nmsocket_t *sock = NULL; + + REQUIRE(VALID_NMHANDLE(handle)); + + sock = handle->sock; REQUIRE(VALID_NMSOCK(sock)); @@ -814,7 +810,7 @@ isc__nm_tcp_resumeread(isc_nmhandle_t *handle) { if (!isc__nmsocket_active(sock)) { sock->reading = true; - failed_read_cb(sock, ISC_R_CANCELED); + isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED); return; } @@ -840,7 +836,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { REQUIRE(buf != NULL); if (isc__nmsocket_closing(sock)) { - failed_read_cb(sock, ISC_R_CANCELED); + isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED); goto free; } @@ -850,7 +846,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { sock->statsindex[STATID_RECVFAIL]); } - failed_read_cb(sock, isc__nm_uverr2result(nread)); + isc__nm_tcp_failed_read_cb(sock, isc__nm_uverr2result(nread)); goto free; } @@ -1339,7 +1335,7 @@ isc__nm_tcp_shutdown(isc_nmsocket_t *sock) { } if (sock->statichandle != NULL) { - failed_read_cb(sock, ISC_R_CANCELED); + isc__nm_tcp_failed_read_cb(sock, ISC_R_CANCELED); return; } @@ -1379,7 +1375,7 @@ isc__nm_async_tcpcancel(isc__networker_t *worker, isc__netievent_t *ev0) { uv_timer_stop(&sock->timer); - failed_read_cb(sock, ISC_R_EOF); + isc__nm_tcp_failed_read_cb(sock, ISC_R_EOF); } int_fast32_t