.B tcp-idle-timeout: \fI<msec>\fR
The period Unbound will wait for a query on a TCP connection.
If this timeout expires Unbound closes the connection.
-This option defaults to 30000 milliseconds. A mimum timeout of
-200 milliseconds is observed regardless of the configured timeout.
+This option defaults to 30000 milliseconds.
When the number of free incoming TCP buffers falls below 50% of the
-total number configured, the timeout is reduced to the minimum.
+total number configured, the option value used is progressively
+reduced, first to 1% of the configured value, then to 0.2% of the
+configured value if the number of free buffers falls below 35% of the
+total number configured, and finally to 0 if the number of free buffers
+falls below 20% of the total number configured. A minimum timeout of
+200 milliseconds is observed regardless of the option value used.
.TP
.B edns-tcp-keepalive: \fI<yes or no>\fR
Enable or disable EDNS TCP Keepalive. Default is no.
close the connection before the server times out.
This option defaults to 120000 milliseconds.
When the number of free incoming TCP buffers falls below 50% of
-the total number configured, the advertised timeout is reduced to 0.
+the total number configured, the advertised timeout is progressively
+reduced to 1% of the configured value, then to 0.2% of the configured
+value if the number of free buffers falls below 35% of the total number
+configured, and finally to 0 if the number of free buffers falls below
+20% of the total number configured.
A minimum actual timeout of 200 milliseconds is observed regardless of the
advertised timeout.
.TP
static void
setup_tcp_handler(struct comm_point* c, int fd, int cur, int max)
{
+ int handler_usage;
log_assert(c->type == comm_tcp);
log_assert(c->fd == -1);
sldns_buffer_clear(c->buffer);
/* if more than half the tcp handlers are in use, use a shorter
* timeout for this TCP connection, we need to make space for
* other connections to be able to get attention */
- if(cur > max/2)
+ handler_usage = (cur * 100) / max;
+ if(handler_usage > 50 && handler_usage <= 65)
+ c->tcp_timeout_msec /= 100;
+ else if (handler_usage > 65 && handler_usage <= 80)
+ c->tcp_timeout_msec /= 500;
+ else if (handler_usage > 80)
c->tcp_timeout_msec = 0;
comm_point_start_listening(c, fd,
c->tcp_timeout_msec < TCP_QUERY_TIMEOUT_MINIMUM