]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use a suitable response in tcp_connected() when initiating a read
authorAram Sargsyan <aram@isc.org>
Thu, 19 Dec 2024 14:22:54 +0000 (14:22 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Wed, 22 Jan 2025 13:40:45 +0000 (13:40 +0000)
When 'ISC_R_TIMEDOUT' is received in 'tcp_recv()', it times out the
oldest response in the active responses queue, and only after that it
checks whether other active responses have also timed out. So when
setting a timeout value for a read operation after a successful
connection, it makes sense to take the timeout value from the oldest
response in the active queue too, because, theoretically, the responses
can have different timeout values, e.g. when the TCP dispatch is shared.
Currently 'resp' is always NULL. Previously when connect and read
timeouts were not separated in dispatch this affected only logging, but
now since we are setting a new timeout after a successful connection,
we need to choose a suitable response from the active queue.

lib/dns/dispatch.c

index 53c8b4b8a4ed0bf50e94b8872c1b42eb86639dce..12f3d9c5a2c6d65afbad6c3f842b79e4b9a4ebcb 100644 (file)
@@ -1871,18 +1871,17 @@ tcp_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
                }
        }
 
-       if (ISC_LIST_EMPTY(disp->active)) {
+       /* Take the oldest active response. */
+       resp = ISC_LIST_HEAD(disp->active);
+       if (resp == NULL) {
                /* All responses have been canceled */
                disp->state = DNS_DISPATCHSTATE_CANCELED;
        } else if (eresult == ISC_R_SUCCESS) {
                disp->state = DNS_DISPATCHSTATE_CONNECTED;
                isc_nmhandle_attach(handle, &disp->handle);
-               if (resp != NULL) {
-                       isc_nmhandle_cleartimeout(disp->handle);
-                       if (resp->timeout != 0) {
-                               isc_nmhandle_settimeout(disp->handle,
-                                                       resp->timeout);
-                       }
+               isc_nmhandle_cleartimeout(disp->handle);
+               if (resp->timeout != 0) {
+                       isc_nmhandle_settimeout(disp->handle, resp->timeout);
                }
                tcp_startrecv(disp, resp);
        } else {