From: Artem Boldariev Date: Fri, 2 Dec 2022 08:41:28 +0000 (+0200) Subject: DoH: Avoid accessing non-atomic listener socket flags when accepting X-Git-Tag: v9.19.8~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b7e1235282a9e74efdb031920861381330e69ef;p=thirdparty%2Fbind9.git DoH: Avoid accessing non-atomic listener socket flags when accepting This commit ensures that the non-atomic flags inside a DoH listener socket object (and associated worker) are accessed when doing accept for a connection only from within the context of the dedicated thread, but not other worker threads. The purpose of this commit is to avoid TSAN errors during isc__nmsocket_closing() calls. It is a continuation of 4b5559cd8f41e67bf03e92d9d0338dee9d549b48. --- diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index bd4a02ed682..7b1d6f7ece6 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -2459,7 +2459,9 @@ httplisten_acceptcb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) { * function gets invoked, so we need to do extra sanity checks to * detect this case. */ - if (isc__nmsocket_closing(handle->sock) || httpserver == NULL) { + if (isc__nm_closing(handle->sock->worker)) { + return (ISC_R_SHUTTINGDOWN); + } else if (isc__nmsocket_closing(handle->sock) || httpserver == NULL) { return (ISC_R_CANCELED); } @@ -2471,9 +2473,7 @@ httplisten_acceptcb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) { REQUIRE(VALID_NMSOCK(httplistensock)); INSIST(httplistensock == httpserver); - if (isc__nmsocket_closing(httplistensock) || - !atomic_load(&httplistensock->listening)) - { + if (atomic_load(&httplistensock->closing)) { return (ISC_R_CANCELED); }