2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

On shutdown, reset the established TCP connections

Previously, the established TCP connections (both client and server)
would be gracefully closed waiting for the write timeout.

Don't wait for TCP connections to gracefully shutdown, but directly
reset them for faster shutdown.
This commit is contained in:
Ondřej Surý
2022-03-10 13:58:58 +01:00
parent a761aa59e3
commit 6ddac2d56d

View File

@@ -2811,6 +2811,7 @@ reset_shutdown(uv_handle_t *handle) {
isc_nmsocket_t *sock = uv_handle_get_data(handle); isc_nmsocket_t *sock = uv_handle_get_data(handle);
isc__nmsocket_shutdown(sock); isc__nmsocket_shutdown(sock);
isc__nmsocket_detach(&sock);
} }
void void
@@ -2833,14 +2834,19 @@ isc__nmsocket_reset(isc_nmsocket_t *sock) {
break; break;
} }
if (!uv_is_closing(&sock->uv_handle.handle)) { if (!uv_is_closing(&sock->uv_handle.handle) &&
uv_is_active(&sock->uv_handle.handle))
{
/* /*
* The real shutdown will be handled in the respective * The real shutdown will be handled in the respective
* close functions. * close functions.
*/ */
isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
int r = uv_tcp_close_reset(&sock->uv_handle.tcp, int r = uv_tcp_close_reset(&sock->uv_handle.tcp,
reset_shutdown); reset_shutdown);
UV_RUNTIME_CHECK(uv_tcp_close_reset, r); UV_RUNTIME_CHECK(uv_tcp_close_reset, r);
} else {
isc__nmsocket_shutdown(sock);
} }
} }
@@ -2882,13 +2888,27 @@ shutdown_walk_cb(uv_handle_t *handle, void *arg) {
switch (handle->type) { switch (handle->type) {
case UV_UDP: case UV_UDP:
isc__nmsocket_shutdown(sock);
return;
case UV_TCP: case UV_TCP:
break; switch (sock->type) {
case isc_nm_tcpsocket:
case isc_nm_tcpdnssocket:
case isc_nm_tlsdnssocket:
if (sock->parent == NULL) {
/* Reset the TCP connections on shutdown */
isc__nmsocket_reset(sock);
return;
}
/* FALLTHROUGH */
default:
isc__nmsocket_shutdown(sock);
}
return;
default: default:
return; return;
} }
isc__nmsocket_shutdown(sock);
} }
void void