2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

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.
This commit is contained in:
Artem Boldariev 2022-12-02 10:41:28 +02:00
parent 4d0c226375
commit 8b7e123528

View File

@ -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);
}