Commit 953d704b authored by Michał Kępień's avatar Michał Kępień

Fix idle timeout for connected TCP sockets

When named acting as a resolver connects to an authoritative server over
TCP, it sets the idle timeout for that connection to 20 seconds.  This
fixed timeout was picked back when the default processing timeout for
each client query was hardcoded to 30 seconds.  Commit
000a8970 made this processing timeout
configurable through "resolver-query-timeout" and decreased its default
value to 10 seconds, but the idle TCP timeout was not adjusted to
reflect that change.  As a result, with the current defaults in effect,
a single hung TCP connection will consistently cause the resolution
process for a given query to time out.

Set the idle timeout for connected TCP sockets to half of the client
query processing timeout configured for a resolver.  This allows named
to handle hung TCP connections more robustly and prevents the timeout
mismatch issue from resurfacing in the future if the default is ever
changed again.
parent e7771dc9
...@@ -3012,12 +3012,15 @@ resquery_connected(isc_task_t *task, isc_event_t *event) { ...@@ -3012,12 +3012,15 @@ resquery_connected(isc_task_t *task, isc_event_t *event) {
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
/* /*
* Extend the idle timer for TCP. 20 seconds * Extend the idle timer for TCP. Half of
* should be long enough for a TCP connection to be * "resolver-query-timeout" will hopefully be long
* established, a single DNS request to be sent, * enough for a TCP connection to be established, a
* and the response received. * single DNS request to be sent, and the response
* received.
*/ */
isc_interval_set(&interval, 20, 0); isc_interval_set(&interval,
fctx->res->query_timeout / 1000 / 2,
0);
result = fctx_startidletimer(query->fctx, &interval); result = fctx_startidletimer(query->fctx, &interval);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
FCTXTRACE("query canceled: idle timer failed; " FCTXTRACE("query canceled: idle timer failed; "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment