2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Destroy netmgr before destroying taskmgr

With taskmgr running on top of netmgr, the ordering of how the tasks and
netmgr shutdown interacts was wrong as previously isc_taskmgr_destroy()
was waiting until all tasks were properly shutdown and detached.  This
responsibility was moved to netmgr, so we now need to do the following:

  1. shutdown all the tasks - this schedules all shutdown events onto
     the netmgr queue

  2. shutdown the netmgr - this also makes sure all the tasks and
     events are properly executed

  3. Shutdown the taskmgr - this now waits for all the tasks to finish
     running before returning

  4. Shutdown the netmgr - this call waits for all the netmgr netievents
     to finish before returning

This solves the race when the taskmgr object would be destroyed before
all the tasks were finished running in the netmgr loops.
This commit is contained in:
Ondřej Surý
2021-04-27 10:28:40 +02:00
committed by Evan Hunt
parent a011d42211
commit b5bf58b419
14 changed files with 155 additions and 103 deletions

View File

@@ -474,7 +474,7 @@ isc_nm_detach(isc_nm_t **mgr0) {
}
void
isc_nm_closedown(isc_nm_t *mgr) {
isc__netmgr_shutdown(isc_nm_t *mgr) {
REQUIRE(VALID_NM(mgr));
atomic_store(&mgr->closing, true);
@@ -497,7 +497,7 @@ isc__netmgr_destroy(isc_nm_t **netmgrp) {
/*
* Close active connections.
*/
isc_nm_closedown(mgr);
isc__netmgr_shutdown(mgr);
/*
* Wait for the manager to be dereferenced elsewhere.