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

Fix the data race when read-writing sock->active by using cmpxchg

This commit is contained in:
Ondřej Surý
2020-10-22 10:07:56 +02:00
committed by Evan Hunt
parent 5ef71c420f
commit 8797e5efd5
6 changed files with 49 additions and 28 deletions

View File

@@ -262,16 +262,12 @@ isc__nm_udp_stoplistening(isc_nmsocket_t *sock) {
REQUIRE(sock->type == isc_nm_udplistener);
/*
* Socket is already closing; there's nothing to do.
* If the socket is active, mark it inactive and
* continue. If it isn't active, stop now.
*/
if (!isc__nmsocket_active(sock)) {
if (!isc__nmsocket_deactivate(sock)) {
return;
}
/*
* Mark it inactive now so that all sends will be ignored
* and we won't try to stop listening again.
*/
atomic_store(&sock->active, false);
/*
* If the manager is interlocked, re-enqueue this as an asynchronous