]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix TCP timeout recovery
authorEvan Hunt <each@isc.org>
Wed, 21 Apr 2021 17:27:46 +0000 (10:27 -0700)
committerEvan Hunt <each@isc.org>
Thu, 22 Apr 2021 19:08:04 +0000 (12:08 -0700)
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

index f950ba2646036613c3f862ba03d6675e99d4179e..80ce1193c2b1f9a676aea52b961226c04a041a48 100644 (file)
@@ -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) {
+       isc__netievent_tcppauseread_t *ievent = NULL;
+       isc_nmsocket_t *sock = NULL;
+
        REQUIRE(VALID_NMHANDLE(handle));
-       REQUIRE(VALID_NMSOCK(handle->sock));
 
-       isc__netievent_tcppauseread_t *ievent = NULL;
-       isc_nmsocket_t *sock = handle->sock;
+       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