mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-10 00:10:00 -04:00
Refactor dns_kasp_attach/detach
Replace implementation with ISC_REFCOUNT_IMPL.
This commit is contained in:
parent
fafe59c745
commit
b68069f275
2 changed files with 19 additions and 52 deletions
|
|
@ -34,6 +34,20 @@
|
|||
#include <dns/name.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
/* Add -DDNS_KASP_TRACE=1 to CFLAGS for detailed reference tracing */
|
||||
|
||||
#if DNS_KASP_TRACE
|
||||
#define dns_kasp_ref(ptr) dns_kasp_ref(ptr, __func__, __FILE__, __LINE__)
|
||||
#define dns_kasp_unref(ptr) dns_kasp__unref(ptr, __func__, __FILE__, __LINE__)
|
||||
#define dns_kasp_attach(ptr, ptrp) \
|
||||
dns_kasp__attach(ptr, ptrp, __func__, __FILE__, __LINE__)
|
||||
#define dns_kasp_detach(ptrp) \
|
||||
dns_kasp__detach(ptrp, __func__, __FILE__, __LINE__)
|
||||
ISC_REFCOUNT_TRACE_DECL(dns_kasp);
|
||||
#else
|
||||
ISC_REFCOUNT_DECL(dns_kasp);
|
||||
#endif
|
||||
|
||||
/* For storing a list of digest types */
|
||||
struct dns_kasp_digest {
|
||||
dns_dsdigest_t digest;
|
||||
|
|
@ -156,38 +170,6 @@ dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp);
|
|||
* Returns:
|
||||
*/
|
||||
|
||||
void
|
||||
dns_kasp_attach(dns_kasp_t *source, dns_kasp_t **targetp);
|
||||
/*%<
|
||||
* Attach '*targetp' to 'source'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'source' is a valid, frozen kasp.
|
||||
*
|
||||
*\li 'targetp' points to a NULL dns_kasp_t *.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *targetp is attached to source.
|
||||
*
|
||||
*\li While *targetp is attached, the kasp will not shut down.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_kasp_detach(dns_kasp_t **kaspp);
|
||||
/*%<
|
||||
* Detach KASP.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'kaspp' points to a valid dns_kasp_t *
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *kaspp is NULL.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_kasp_freeze(dns_kasp_t *kasp);
|
||||
/*%<
|
||||
|
|
|
|||
|
|
@ -56,15 +56,6 @@ dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp) {
|
|||
*kaspp = kasp;
|
||||
}
|
||||
|
||||
void
|
||||
dns_kasp_attach(dns_kasp_t *source, dns_kasp_t **targetp) {
|
||||
REQUIRE(DNS_KASP_VALID(source));
|
||||
REQUIRE(targetp != NULL && *targetp == NULL);
|
||||
|
||||
isc_refcount_increment(&source->references);
|
||||
*targetp = source;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy(dns_kasp_t *kasp) {
|
||||
REQUIRE(!ISC_LINK_LINKED(kasp, link));
|
||||
|
|
@ -86,17 +77,11 @@ destroy(dns_kasp_t *kasp) {
|
|||
isc_mem_putanddetach(&kasp->mctx, kasp, sizeof(*kasp));
|
||||
}
|
||||
|
||||
void
|
||||
dns_kasp_detach(dns_kasp_t **kaspp) {
|
||||
REQUIRE(kaspp != NULL && DNS_KASP_VALID(*kaspp));
|
||||
|
||||
dns_kasp_t *kasp = *kaspp;
|
||||
*kaspp = NULL;
|
||||
|
||||
if (isc_refcount_decrement(&kasp->references) == 1) {
|
||||
destroy(kasp);
|
||||
}
|
||||
}
|
||||
#if DNS_KASP_TRACE
|
||||
ISC_REFCOUNT_TRACE_IMPL(dns_kasp, destroy);
|
||||
#else
|
||||
ISC_REFCOUNT_IMPL(dns_kasp, destroy);
|
||||
#endif
|
||||
|
||||
const char *
|
||||
dns_kasp_getname(dns_kasp_t *kasp) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue