From 58663574b9ee160ca7880f004ed10ed5947b9be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 18 Apr 2023 14:35:34 +0200 Subject: [PATCH] Use server socket to log TCP accept failures The accept_connection() could detach from the child socket on a failure, so we need to keep and use the server socket for logging the accept failures. --- lib/isc/netmgr/tcp.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 11b05b639e..10a71a6d2e 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -795,19 +795,21 @@ free: */ static void tcpaccept_cb(void *arg) { - isc_nmsocket_t *sock = arg; + isc_nmsocket_t *csock = arg; + isc_nmsocket_t *ssock = csock->server; - REQUIRE(VALID_NMSOCK(sock)); - REQUIRE(sock->tid == isc_tid()); + REQUIRE(VALID_NMSOCK(csock)); + REQUIRE(csock->tid == isc_tid()); - isc_result_t result = accept_connection(sock); - isc__nm_accept_connection_log(sock, result, can_log_tcp_quota()); - isc__nmsocket_detach(&sock); + isc_result_t result = accept_connection(csock); + isc__nm_accept_connection_log(ssock, result, can_log_tcp_quota()); + isc__nmsocket_detach(&csock); } static void quota_accept_cb(void *arg) { isc_nmsocket_t *csock = arg; + isc_nmsocket_t *ssock = csock->server; REQUIRE(VALID_NMSOCK(csock)); @@ -817,7 +819,7 @@ quota_accept_cb(void *arg) { */ if (csock->tid == isc_tid()) { isc_result_t result = accept_connection(csock); - isc__nm_accept_connection_log(csock, result, + isc__nm_accept_connection_log(ssock, result, can_log_tcp_quota()); } else { isc__nmsocket_attach(csock, &(isc_nmsocket_t *){ NULL });