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

Add new isc_managers API to simplify <*>mgr create/destroy

Previously, netmgr, taskmgr, timermgr and socketmgr all had their own
isc_<*>mgr_create() and isc_<*>mgr_destroy() functions.  The new
isc_managers_create() and isc_managers_destroy() fold all four into a
single function and makes sure the objects are created and destroy in
correct order.

Especially now, when taskmgr runs on top of netmgr, the correct order is
important and when the code was duplicated at many places it's easy to
make mistake.

The former isc_<*>mgr_create() and isc_<*>mgr_destroy() functions were
made private and a single call to isc_managers_create() and
isc_managers_destroy() is required at the program startup / shutdown.
This commit is contained in:
Ondřej Surý
2021-04-27 00:07:43 +02:00
committed by Evan Hunt
parent f23afce683
commit a011d42211
48 changed files with 591 additions and 616 deletions

View File

@@ -37,6 +37,7 @@
#include <isc/util.h>
#include "netmgr-int.h"
#include "netmgr_p.h"
#include "openssl_shim.h"
#include "uv-compat.h"
@@ -206,8 +207,8 @@ isc__nm_winsock_destroy(void) {
}
#endif /* WIN32 */
isc_nm_t *
isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
void
isc__netmgr_create(isc_mem_t *mctx, uint32_t workers, isc_nm_t **netmgrp) {
isc_nm_t *mgr = NULL;
char name[32];
@@ -296,7 +297,7 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
}
mgr->magic = NM_MAGIC;
return (mgr);
*netmgrp = mgr;
}
/*
@@ -485,14 +486,13 @@ isc_nm_closedown(isc_nm_t *mgr) {
}
void
isc_nm_destroy(isc_nm_t **mgr0) {
isc__netmgr_destroy(isc_nm_t **netmgrp) {
isc_nm_t *mgr = NULL;
int counter = 0;
REQUIRE(mgr0 != NULL);
REQUIRE(VALID_NM(*mgr0));
REQUIRE(VALID_NM(*netmgrp));
mgr = *mgr0;
mgr = *netmgrp;
/*
* Close active connections.
@@ -524,7 +524,7 @@ isc_nm_destroy(isc_nm_t **mgr0) {
/*
* Detach final reference.
*/
isc_nm_detach(mgr0);
isc_nm_detach(netmgrp);
}
void