mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
remove ns_interface reference counting
reference counting of ns_interface objects has not been used since the clientmgr cleanup in #2433, and it no longer really makes sense now - when we want to destroy an interface on a rescan, we want it to be destroyed, not kept active by some other caller. so ns_interface_attach() has been removed, ns_interface_detach() has been replaced with a static interface_destroy(), and do_scan() has been simplified accordingly.
This commit is contained in:
@@ -69,7 +69,6 @@ struct ns_interface {
|
|||||||
unsigned int magic; /*%< Magic number. */
|
unsigned int magic; /*%< Magic number. */
|
||||||
ns_interfacemgr_t *mgr; /*%< Interface manager. */
|
ns_interfacemgr_t *mgr; /*%< Interface manager. */
|
||||||
isc_mutex_t lock;
|
isc_mutex_t lock;
|
||||||
isc_refcount_t references;
|
|
||||||
unsigned int generation; /*%< Generation number. */
|
unsigned int generation; /*%< Generation number. */
|
||||||
isc_sockaddr_t addr; /*%< Address and port. */
|
isc_sockaddr_t addr; /*%< Address and port. */
|
||||||
unsigned int flags; /*%< Interface flags */
|
unsigned int flags; /*%< Interface flags */
|
||||||
@@ -163,12 +162,6 @@ ns_interfacemgr_setlistenon6(ns_interfacemgr_t *mgr, ns_listenlist_t *value);
|
|||||||
dns_aclenv_t *
|
dns_aclenv_t *
|
||||||
ns_interfacemgr_getaclenv(ns_interfacemgr_t *mgr);
|
ns_interfacemgr_getaclenv(ns_interfacemgr_t *mgr);
|
||||||
|
|
||||||
void
|
|
||||||
ns_interface_attach(ns_interface_t *source, ns_interface_t **target);
|
|
||||||
|
|
||||||
void
|
|
||||||
ns_interface_detach(ns_interface_t **targetp);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ns_interface_shutdown(ns_interface_t *ifp);
|
ns_interface_shutdown(ns_interface_t *ifp);
|
||||||
/*%<
|
/*%<
|
||||||
|
@@ -499,7 +499,6 @@ interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr, const char *name,
|
|||||||
ISC_LIST_APPEND(mgr->interfaces, ifp, link);
|
ISC_LIST_APPEND(mgr->interfaces, ifp, link);
|
||||||
UNLOCK(&mgr->lock);
|
UNLOCK(&mgr->lock);
|
||||||
|
|
||||||
isc_refcount_init(&ifp->references, 1);
|
|
||||||
ifp->magic = IFACE_MAGIC;
|
ifp->magic = IFACE_MAGIC;
|
||||||
|
|
||||||
*ifpret = ifp;
|
*ifpret = ifp;
|
||||||
@@ -755,8 +754,14 @@ ns_interface_shutdown(ns_interface_t *ifp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
interface_destroy(ns_interface_t *ifp) {
|
interface_destroy(ns_interface_t **interfacep) {
|
||||||
ns_interfacemgr_t *mgr;
|
ns_interface_t *ifp = NULL;
|
||||||
|
ns_interfacemgr_t *mgr = NULL;
|
||||||
|
|
||||||
|
REQUIRE(interfacep != NULL);
|
||||||
|
|
||||||
|
ifp = *interfacep;
|
||||||
|
*interfacep = NULL;
|
||||||
|
|
||||||
REQUIRE(NS_INTERFACE_VALID(ifp));
|
REQUIRE(NS_INTERFACE_VALID(ifp));
|
||||||
|
|
||||||
@@ -777,24 +782,6 @@ interface_destroy(ns_interface_t *ifp) {
|
|||||||
isc_mem_put(mgr->mctx, ifp, sizeof(*ifp));
|
isc_mem_put(mgr->mctx, ifp, sizeof(*ifp));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ns_interface_attach(ns_interface_t *source, ns_interface_t **target) {
|
|
||||||
REQUIRE(NS_INTERFACE_VALID(source));
|
|
||||||
isc_refcount_increment(&source->references);
|
|
||||||
*target = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ns_interface_detach(ns_interface_t **targetp) {
|
|
||||||
ns_interface_t *target = *targetp;
|
|
||||||
*targetp = NULL;
|
|
||||||
REQUIRE(target != NULL);
|
|
||||||
REQUIRE(NS_INTERFACE_VALID(target));
|
|
||||||
if (isc_refcount_decrement(&target->references) == 1) {
|
|
||||||
interface_destroy(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Search the interface list for an interface whose address and port
|
* Search the interface list for an interface whose address and port
|
||||||
* both match those of 'addr'. Return a pointer to it, or NULL if not found.
|
* both match those of 'addr'. Return a pointer to it, or NULL if not found.
|
||||||
@@ -835,7 +822,7 @@ purge_old_interfaces(ns_interfacemgr_t *mgr) {
|
|||||||
"no longer listening on %s", sabuf);
|
"no longer listening on %s", sabuf);
|
||||||
ns_interface_shutdown(ifp);
|
ns_interface_shutdown(ifp);
|
||||||
}
|
}
|
||||||
ns_interface_detach(&ifp);
|
interface_destroy(&ifp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNLOCK(&mgr->lock);
|
UNLOCK(&mgr->lock);
|
||||||
@@ -1028,8 +1015,6 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
|
|||||||
le->sslctx != NULL) {
|
le->sslctx != NULL) {
|
||||||
INSIST(NS_INTERFACE_VALID(ifp));
|
INSIST(NS_INTERFACE_VALID(ifp));
|
||||||
LOCK(&mgr->lock);
|
LOCK(&mgr->lock);
|
||||||
ISC_LIST_UNLINK(ifp->mgr->interfaces,
|
|
||||||
ifp, link);
|
|
||||||
isc_sockaddr_format(&ifp->addr, sabuf,
|
isc_sockaddr_format(&ifp->addr, sabuf,
|
||||||
sizeof(sabuf));
|
sizeof(sabuf));
|
||||||
isc_log_write(IFMGR_COMMON_LOGARGS,
|
isc_log_write(IFMGR_COMMON_LOGARGS,
|
||||||
@@ -1037,8 +1022,7 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
|
|||||||
"no longer listening on "
|
"no longer listening on "
|
||||||
"%s",
|
"%s",
|
||||||
sabuf);
|
sabuf);
|
||||||
ns_interface_shutdown(ifp);
|
interface_destroy(&ifp);
|
||||||
ns_interface_detach(&ifp);
|
|
||||||
UNLOCK(&mgr->lock);
|
UNLOCK(&mgr->lock);
|
||||||
} else {
|
} else {
|
||||||
ifp->generation = mgr->generation;
|
ifp->generation = mgr->generation;
|
||||||
@@ -1206,8 +1190,6 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
|
|||||||
le->sslctx != NULL) {
|
le->sslctx != NULL) {
|
||||||
INSIST(NS_INTERFACE_VALID(ifp));
|
INSIST(NS_INTERFACE_VALID(ifp));
|
||||||
LOCK(&mgr->lock);
|
LOCK(&mgr->lock);
|
||||||
ISC_LIST_UNLINK(ifp->mgr->interfaces,
|
|
||||||
ifp, link);
|
|
||||||
isc_sockaddr_format(&ifp->addr, sabuf,
|
isc_sockaddr_format(&ifp->addr, sabuf,
|
||||||
sizeof(sabuf));
|
sizeof(sabuf));
|
||||||
isc_log_write(IFMGR_COMMON_LOGARGS,
|
isc_log_write(IFMGR_COMMON_LOGARGS,
|
||||||
@@ -1215,8 +1197,7 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
|
|||||||
"no longer listening on "
|
"no longer listening on "
|
||||||
"%s",
|
"%s",
|
||||||
sabuf);
|
sabuf);
|
||||||
ns_interface_shutdown(ifp);
|
interface_destroy(&ifp);
|
||||||
ns_interface_detach(&ifp);
|
|
||||||
UNLOCK(&mgr->lock);
|
UNLOCK(&mgr->lock);
|
||||||
} else {
|
} else {
|
||||||
ifp->generation = mgr->generation;
|
ifp->generation = mgr->generation;
|
||||||
|
Reference in New Issue
Block a user