Export zone functions

Make some zone functions available that we are going to need in the
zonefetch code.
This commit is contained in:
Matthijs Mekking 2025-10-29 15:30:46 +01:00
parent 799fc93619
commit 6adfc2348b
2 changed files with 53 additions and 22 deletions

View file

@ -1168,12 +1168,8 @@ clear_keylist(dns_dnsseckeylist_t *list, isc_mem_t *mctx) {
}
}
/*
* Free a zone. Because we require that there be no more
* outstanding events or references, no locking is necessary.
*/
static void
zone_free(dns_zone_t *zone) {
void
dns__zone_free(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(!LOCKED_ZONE(zone));
REQUIRE(zone->timer == NULL);
@ -5882,8 +5878,8 @@ done:
return result;
}
static bool
exit_check(dns_zone_t *zone) {
bool
dns__zone_free_check(dns_zone_t *zone) {
REQUIRE(LOCKED_ZONE(zone));
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_SHUTDOWN) &&
@ -6241,10 +6237,10 @@ dns_zone_idetach(dns_zone_t **zonep) {
if (isc_refcount_decrement(&zone->irefs) == 1) {
bool free_needed;
LOCK_ZONE(zone);
free_needed = exit_check(zone);
free_needed = dns__zone_free_check(zone);
UNLOCK_ZONE(zone);
if (free_needed) {
zone_free(zone);
dns__zone_free(zone);
}
}
}
@ -6256,6 +6252,13 @@ dns_zone_getmctx(dns_zone_t *zone) {
return zone->mctx;
}
isc_refcount_t *
dns__zone_irefs(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
return &zone->irefs;
}
dns_zonemgr_t *
dns_zone_getmgr(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
@ -14840,12 +14843,12 @@ zone_shutdown(void *arg) {
}
/*
* We have now canceled everything set the flag to allow exit_check()
* to succeed. We must not unlock between setting this flag and
* calling exit_check().
* We have now canceled everything set the flag to allow
* dns__zone_free_check() to succeed. We must not unlock between
* setting this flag and calling dns__zone_free_check().
*/
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_SHUTDOWN);
free_needed = exit_check(zone);
free_needed = dns__zone_free_check(zone);
/*
* If a dump is in progress for the secure zone, defer detaching from
* the raw zone as it may prevent the unsigned serial number from being
@ -14876,7 +14879,7 @@ zone_shutdown(void *arg) {
dns_zone_idetach(&secure);
}
if (free_needed) {
zone_free(zone);
dns__zone_free(zone);
}
}
@ -15075,10 +15078,10 @@ zone__settimer(void *arg) {
free:
isc_mem_put(zone->mctx, data, sizeof(*data));
isc_refcount_decrement(&zone->irefs);
free_needed = exit_check(zone);
free_needed = dns__zone_free_check(zone);
UNLOCK_ZONE(zone);
if (free_needed) {
zone_free(zone);
dns__zone_free(zone);
}
}
@ -17788,10 +17791,10 @@ again:
}
isc_refcount_decrement(&zone->irefs);
free_needed = exit_check(zone);
free_needed = dns__zone_free_check(zone);
UNLOCK_ZONE(zone);
if (free_needed) {
zone_free(zone);
dns__zone_free(zone);
}
}
@ -23723,7 +23726,7 @@ dns_zone_setnsec3param(dns_zone_t *zone, uint8_t hash, uint8_t flags,
* not yet have a database. Prevent that by queueing the event
* up if zone->db is NULL. All events queued here are
* subsequently processed by receive_secure_db() if it ever gets
* called or simply freed by zone_free() otherwise.
* called or simply freed by dns__zone_free() otherwise.
*/
ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);

View file

@ -18,8 +18,8 @@
/*! \file */
/*%
* Types and functions below not be used outside this module and its
* associated unit tests.
* Types and functions below meant to be used for internal zone
* modules only, and associated unit tests.
*/
#define UDP_REQUEST_TIMEOUT 5 /*%< 5 seconds */
@ -185,3 +185,31 @@ dns__zone_idetach_locked(dns_zone_t **zonep);
*\li The caller is running in the context of the zone's loop.
*\li 'zonep' to point to a valid zone, already locked.
*/
isc_refcount_t *
dns__zone_irefs(dns_zone_t *zone);
/*%<
* Get the reference count of a zone.
*
* Requires:
* \li 'zone' to be a valid zone.
*/
void
dns__zone_free(dns_zone_t *zone);
/*
* Free a zone. Because we require that there be no more
* outstanding events or references, no locking is necessary.
*
* Requires:
* \li 'zone' to be a valid zone, unlocked.
*/
bool
dns__zone_free_check(dns_zone_t *zone);
/*
* Check if a zone is ready to be freed.
*
* Requires:
* \li 'zone' to be a valid zone, locked.
*/