]> git.ipfire.org Git - thirdparty/bind9.git/commit
Reset the TCP connection on a failed send
authorOndřej Surý <ondrej@isc.org>
Tue, 2 Jul 2024 18:17:49 +0000 (20:17 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 3 Jul 2024 07:07:20 +0000 (09:07 +0200)
commitbf9fd2a6ff1a81ee2974ad984fda71e096ffb6fb
treed078527e68d2d0586421b5dc60b99b493492b650
parent1c0564d71505dec0ce6545982ffd88f87a3a00e0
Reset the TCP connection on a failed send

When sending fails, the ns__client_request() would not reset the
connection and continue as nothing is happening.  This comes from the
model that we don't care about failed UDP sends because datagrams are
unreliable anyway, but it greatly affects TCP connections with
keep-alive.

The worst case scenario is as follows:

1. the 3-way TCP handshake gets completed
2. the libuv calls the "uv_connection_cb" callback
3. the TCP connection gets queue because of the tcp-clients quota
4. the TCP client sends as many DNS messages as the buffers allow
5. the TCP connection gets dropped by the client due to the timeout
6. the TCP connection gets accepted by the server
7. the data already sent by the client gets read
8. all sending fails immediately because the TCP connection is dead
9. we consume all the data in the buffer in a very tight loop

As it doesn't make sense to trying to process more data on the TCP
connection when the sending is failing, drop the connection immediately
on the first sending error.
lib/ns/client.c