Move dns_zone_next/dns_zone_first to zonemgr

Walking the list of managed zones is a function that operates
on the zone manager object.
This commit is contained in:
Matthijs Mekking 2026-04-07 11:22:56 +02:00
parent a320801042
commit 9c420582be
5 changed files with 64 additions and 64 deletions

View file

@ -4295,9 +4295,9 @@ named_stats_dump(named_server_t *server, FILE *fp) {
fprintf(fp, "++ Per Zone Query Statistics ++\n");
zone = NULL;
for (result = dns_zone_first(server->zonemgr, &zone);
result == ISC_R_SUCCESS;
next = NULL, result = dns_zone_next(zone, &next), zone = next)
for (result = dns_zonemgr_first_zone(server->zonemgr, &zone);
result == ISC_R_SUCCESS; next = NULL,
result = dns_zonemgr_next_zone(zone, &next), zone = next)
{
isc_stats_t *zonestats = dns_zone_getrequeststats(zone);
if (zonestats != NULL) {
@ -4324,9 +4324,9 @@ named_stats_dump(named_server_t *server, FILE *fp) {
fprintf(fp, "++ Per Zone Glue Cache Statistics ++\n");
zone = NULL;
for (result = dns_zone_first(server->zonemgr, &zone);
result == ISC_R_SUCCESS;
next = NULL, result = dns_zone_next(zone, &next), zone = next)
for (result = dns_zonemgr_first_zone(server->zonemgr, &zone);
result == ISC_R_SUCCESS; next = NULL,
result = dns_zonemgr_next_zone(zone, &next), zone = next)
{
isc_stats_t *gluecachestats = dns_zone_getgluecachestats(zone);
if (gluecachestats != NULL) {

View file

@ -523,38 +523,6 @@ dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
*\li Others
*/
isc_result_t
dns_zone_next(dns_zone_t *zone, dns_zone_t **next);
/*%<
* Find the next zone in the list of managed zones.
*
* Requires:
*\li 'zone' to be valid
*\li The zone manager for the indicated zone MUST be locked
* by the caller. This is not checked.
*\li 'next' be non-NULL, and '*next' be NULL.
*
* Ensures:
*\li 'next' points to a valid zone (result ISC_R_SUCCESS) or to NULL
* (result ISC_R_NOMORE).
*/
isc_result_t
dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first);
/*%<
* Find the first zone in the list of managed zones.
*
* Requires:
*\li 'zonemgr' to be valid
*\li The zone manager for the indicated zone MUST be locked
* by the caller. This is not checked.
*\li 'first' be non-NULL, and '*first' be NULL
*
* Ensures:
*\li 'first' points to a valid zone (result ISC_R_SUCCESS) or to NULL
* (result ISC_R_NOMORE).
*/
isc_result_t
dns_zone_getdnsseckeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
isc_stdtime_t now, dns_dnsseckeylist_t *keys);

View file

@ -223,3 +223,35 @@ dns_zonemgr_set_tlsctx_cache(dns_zonemgr_t *zmgr,
*\li 'zmgr' is a valid zone manager.
*\li 'tlsctx_cache' is a valid TLS context cache.
*/
isc_result_t
dns_zonemgr_next_zone(dns_zone_t *zone, dns_zone_t **next);
/*%<
* Find the next zone in the list of managed zones.
*
* Requires:
*\li 'zone' to be valid
*\li The zone manager for the indicated zone MUST be locked
* by the caller. This is not checked.
*\li 'next' be non-NULL, and '*next' be NULL.
*
* Ensures:
*\li 'next' points to a valid zone (result ISC_R_SUCCESS) or to NULL
* (result ISC_R_NOMORE).
*/
isc_result_t
dns_zonemgr_first_zone(dns_zonemgr_t *zmgr, dns_zone_t **first);
/*%<
* Find the first zone in the list of managed zones.
*
* Requires:
*\li 'zonemgr' to be valid
*\li The zone manager for the indicated zone MUST be locked
* by the caller. This is not checked.
*\li 'first' be non-NULL, and '*first' be NULL
*
* Ensures:
*\li 'first' points to a valid zone (result ISC_R_SUCCESS) or to NULL
* (result ISC_R_NOMORE).
*/

View file

@ -15972,32 +15972,6 @@ cleanup:
return result;
}
isc_result_t
dns_zone_next(dns_zone_t *zone, dns_zone_t **next) {
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(next != NULL && *next == NULL);
*next = ISC_LIST_NEXT(zone, link);
if (*next == NULL) {
return ISC_R_NOMORE;
} else {
return ISC_R_SUCCESS;
}
}
isc_result_t
dns_zone_first(dns_zonemgr_t *zmgr, dns_zone_t **first) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
REQUIRE(first != NULL && *first == NULL);
*first = ISC_LIST_HEAD(zmgr->zones);
if (*first == NULL) {
return ISC_R_NOMORE;
} else {
return ISC_R_SUCCESS;
}
}
static isc_mutex_t *
zone_keymgmt_getlock(dns_zone_t *zone) {
uint32_t hash = dns_name_hash(&zone->origin);

View file

@ -810,3 +810,29 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, dns_zonestate_t state) {
return count;
}
isc_result_t
dns_zonemgr_next_zone(dns_zone_t *zone, dns_zone_t **next) {
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(next != NULL && *next == NULL);
*next = ISC_LIST_NEXT(zone, link);
if (*next == NULL) {
return ISC_R_NOMORE;
} else {
return ISC_R_SUCCESS;
}
}
isc_result_t
dns_zonemgr_first_zone(dns_zonemgr_t *zmgr, dns_zone_t **first) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
REQUIRE(first != NULL && *first == NULL);
*first = ISC_LIST_HEAD(zmgr->zones);
if (*first == NULL) {
return ISC_R_NOMORE;
} else {
return ISC_R_SUCCESS;
}
}