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

General code refactoring

- style cleanup
- removed NULL checks in places where they are not currently needed
- use isc_refcount for dispatch reference counting
- revised code flow for readability
- remove some #ifdefs that are no longer relevant
- remove unused struct members
- removed unnecessary function parameters
- use C99 struct initialization
This commit is contained in:
Evan Hunt
2020-12-09 19:44:41 -08:00
committed by Ondřej Surý
parent 5863acc907
commit 300392ae2f
7 changed files with 283 additions and 500 deletions

View File

@@ -86,7 +86,6 @@ struct ns_interfacemgr {
ISC_LIST(ns_interface_t) interfaces; /*%< List of interfaces */
ISC_LIST(isc_sockaddr_t) listenon;
int backlog; /*%< Listen queue size */
unsigned int udpdisp; /*%< UDP dispatch count */
atomic_bool shuttingdown; /*%< Interfacemgr shutting down */
ns_clientmgr_t **clientmgrs; /*%< Client managers */
#ifdef USE_ROUTE_SOCKET
@@ -183,8 +182,8 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr,
isc_socketmgr_t *socketmgr, isc_nm_t *nm,
dns_dispatchmgr_t *dispatchmgr, isc_task_t *task,
unsigned int udpdisp, dns_geoip_databases_t *geoip,
int ncpus, ns_interfacemgr_t **mgrp) {
dns_geoip_databases_t *geoip, int ncpus,
ns_interfacemgr_t **mgrp) {
isc_result_t result;
ns_interfacemgr_t *mgr;
@@ -220,7 +219,6 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
mgr->generation = 1;
mgr->listenon4 = NULL;
mgr->listenon6 = NULL;
mgr->udpdisp = udpdisp;
mgr->ncpus = ncpus;
atomic_init(&mgr->shuttingdown, false);
@@ -404,8 +402,7 @@ ns_interfacemgr_shutdown(ns_interfacemgr_t *mgr) {
static isc_result_t
ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
const char *name, ns_interface_t **ifpret) {
ns_interface_t *ifp;
int disp;
ns_interface_t *ifp = NULL;
REQUIRE(NS_INTERFACEMGR_VALID(mgr));
@@ -418,10 +415,6 @@ ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
isc_mutex_init(&ifp->lock);
for (disp = 0; disp < MAX_UDP_DISPATCH; disp++) {
ifp->udpdispatch[disp] = NULL;
}
/*
* Create a single TCP client object. It will replace itself
* with a new one as soon as it gets a connection, so the actual
@@ -705,12 +698,6 @@ ns_interface_destroy(ns_interface_t *ifp) {
ns_interface_shutdown(ifp);
for (int disp = 0; disp < ifp->nudpdispatch; disp++) {
if (ifp->udpdispatch[disp] != NULL) {
dns_dispatch_detach(&(ifp->udpdispatch[disp]));
}
}
if (ifp->tcpsocket != NULL) {
isc_socket_detach(&ifp->tcpsocket);
}