From 4b5559cd8f41e67bf03e92d9d0338dee9d549b48 Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Wed, 30 Nov 2022 22:58:13 +0200 Subject: [PATCH] TLS: Avoid accessing listener socket flags from other threads This commit ensures that the flags inside a TLS listener socket object (and associated worker) are accessed when accepting a connection only from within the context of the dedicated thread, but not other worker threads. --- lib/isc/netmgr/tlsstream.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index f8a0bc6dc2..4a2497d526 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -687,10 +687,9 @@ tlslisten_acceptcb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) { REQUIRE(VALID_NMSOCK(tlslistensock)); REQUIRE(tlslistensock->type == isc_nm_tlslistener); - if (isc__nmsocket_closing(handle->sock) || - isc__nmsocket_closing(tlslistensock) || - !atomic_load(&tlslistensock->listening)) - { + if (isc__nm_closing(handle->sock->worker)) { + return (ISC_R_SHUTTINGDOWN); + } else if (isc__nmsocket_closing(handle->sock)) { return (ISC_R_CANCELED); }