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

Merge branch '1494-lock-order-inversion-potential-deadlock-nm_thread-vs-nm_destroy' into 'master'

Resolve "lock-order-inversion (potential deadlock) - nm_thread vs nm_destroy"

Closes #1494

See merge request isc-projects/bind9!2763
This commit is contained in:
Mark Andrews
2019-12-12 08:26:24 +00:00

View File

@@ -168,7 +168,6 @@ nm_destroy(isc_nm_t **mgr0) {
isc_refcount_destroy(&mgr->references); isc_refcount_destroy(&mgr->references);
LOCK(&mgr->lock);
mgr->magic = 0; mgr->magic = 0;
for (size_t i = 0; i < mgr->nworkers; i++) { for (size_t i = 0; i < mgr->nworkers; i++) {
@@ -181,6 +180,7 @@ nm_destroy(isc_nm_t **mgr0) {
isc__nm_enqueue_ievent(&mgr->workers[i], event); isc__nm_enqueue_ievent(&mgr->workers[i], event);
} }
LOCK(&mgr->lock);
while (atomic_load(&mgr->workers_running) > 0) { while (atomic_load(&mgr->workers_running) > 0) {
WAIT(&mgr->wkstatecond, &mgr->lock); WAIT(&mgr->wkstatecond, &mgr->lock);
} }