]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
allow streamdns read to resume after timeout
authorEvan Hunt <each@isc.org>
Sun, 14 May 2023 06:31:45 +0000 (23:31 -0700)
committerEvan Hunt <each@isc.org>
Sun, 14 May 2023 06:31:45 +0000 (23:31 -0700)
when reading on a streamdns socket failed due to timeout, but
the dispatch was still waiting for other responses, it would
resume reading by calling isc_nm_read() again. this caused
an assertion because the socket was already reading.

we now check that either the socket is reading, or that it was
already reading on the same handle.

lib/isc/netmgr/streamdns.c

index 64b20ff735e435b94880cb233699838d307af97d..af312506c71b3f5a3a61f77bc041ebff71145e89 100644 (file)
@@ -831,7 +831,7 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb,
        sock = handle->sock;
        REQUIRE(VALID_NMSOCK(sock));
        REQUIRE(sock->type == isc_nm_streamdnssocket);
-       REQUIRE(sock->recv_handle == NULL);
+       REQUIRE(sock->recv_handle == handle || sock->recv_handle == NULL);
        REQUIRE(sock->tid == isc_tid());
 
        closing = streamdns_closing(sock);
@@ -839,7 +839,9 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb,
        sock->recv_cb = cb;
        sock->recv_cbarg = cbarg;
        sock->reading = true;
-       isc_nmhandle_attach(handle, &sock->recv_handle);
+       if (sock->recv_handle == NULL) {
+               isc_nmhandle_attach(handle, &sock->recv_handle);
+       }
 
        /*
         * In some cases there is little sense in making the operation