Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea33acffd4 | ||
|
|
4f21dbb7a2 | ||
|
|
a53c87370e | ||
|
|
ede56bf009 |
+3
-3
@@ -1588,7 +1588,7 @@ clear_query(dig_query_t *query) {
|
||||
if (query->waiting_senddone) {
|
||||
query->pending_free = true;
|
||||
} else {
|
||||
query->magic = 0;
|
||||
ISC_MAGIC_CLEAR(query);
|
||||
isc_mem_free(mctx, query);
|
||||
}
|
||||
}
|
||||
@@ -2553,7 +2553,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
ISC_LINK_INIT(query, clink);
|
||||
ISC_LINK_INIT(query, link);
|
||||
|
||||
query->magic = DIG_QUERY_MAGIC;
|
||||
ISC_MAGIC_INIT(query, DIG_QUERY_MAGIC);
|
||||
|
||||
ISC_LIST_ENQUEUE(lookup->q, query, link);
|
||||
}
|
||||
@@ -2599,7 +2599,7 @@ send_done(isc_task_t *_task, isc_event_t *event) {
|
||||
isc_event_free(&event);
|
||||
|
||||
if (query->pending_free) {
|
||||
query->magic = 0;
|
||||
ISC_MAGIC_CLEAR(query);
|
||||
isc_mem_free(mctx, query);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ struct dig_lookup {
|
||||
|
||||
/*% The dig_query structure */
|
||||
struct dig_query {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dig_lookup_t *lookup;
|
||||
bool waiting_connect,
|
||||
pending_free,
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
* Name server state. Better here than in lots of separate global variables.
|
||||
*/
|
||||
struct named_server {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
|
||||
ns_server_t * sctx;
|
||||
|
||||
+8
-7
@@ -302,9 +302,10 @@ typedef struct catz_chgzone_event {
|
||||
bool mod;
|
||||
} catz_chgzone_event_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int magic;
|
||||
#define DZARG_MAGIC ISC_MAGIC('D', 'z', 'a', 'r')
|
||||
|
||||
typedef struct {
|
||||
isc_magic_t magic;
|
||||
isc_buffer_t **text;
|
||||
isc_result_t result;
|
||||
} ns_dzarg_t;
|
||||
@@ -9959,7 +9960,7 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
|
||||
|
||||
server->dtenv = NULL;
|
||||
|
||||
server->magic = NAMED_SERVER_MAGIC;
|
||||
ISC_MAGIC_INIT(server, NAMED_SERVER_MAGIC);
|
||||
*serverp = server;
|
||||
}
|
||||
|
||||
@@ -10010,7 +10011,7 @@ named_server_destroy(named_server_t **serverp) {
|
||||
INSIST(ISC_LIST_EMPTY(server->viewlist));
|
||||
INSIST(ISC_LIST_EMPTY(server->cachelist));
|
||||
|
||||
server->magic = 0;
|
||||
ISC_MAGIC_CLEAR(server);
|
||||
isc_mem_put(server->mctx, server, sizeof(*server));
|
||||
*serverp = NULL;
|
||||
}
|
||||
@@ -12446,7 +12447,7 @@ nzd_save(MDB_txn **txnp, MDB_dbi dbi, dns_zone_t *zone,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dzarg.magic = DZARG_MAGIC;
|
||||
ISC_MAGIC_INIT(&dzarg, DZARG_MAGIC);
|
||||
dzarg.text = &text;
|
||||
dzarg.result = ISC_R_SUCCESS;
|
||||
cfg_printx(zoptions, CFG_PRINTER_ONELINE, dumpzone, &dzarg);
|
||||
@@ -12829,7 +12830,7 @@ migrate_nzf(dns_view_t *view) {
|
||||
}
|
||||
|
||||
isc_buffer_clear(text);
|
||||
dzarg.magic = DZARG_MAGIC;
|
||||
ISC_MAGIC_INIT(&dzarg, DZARG_MAGIC);
|
||||
dzarg.text = &text;
|
||||
dzarg.result = ISC_R_SUCCESS;
|
||||
cfg_printx(zoptions, CFG_PRINTER_ONELINE, dumpzone, &dzarg);
|
||||
@@ -14035,7 +14036,7 @@ named_server_showzone(named_server_t *server, isc_lex_t *lex,
|
||||
CHECK(ISC_R_NOTFOUND);
|
||||
|
||||
CHECK(putstr(text, "zone "));
|
||||
dzarg.magic = DZARG_MAGIC;
|
||||
ISC_MAGIC_INIT(&dzarg, DZARG_MAGIC);
|
||||
dzarg.text = text;
|
||||
dzarg.result = ISC_R_SUCCESS;
|
||||
cfg_printx(zconfig, CFG_PRINTER_ONELINE, emitzone, &dzarg);
|
||||
|
||||
@@ -762,8 +762,8 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
isc_mem_attach(mctx, &sampledb->common.mctx);
|
||||
dns_name_init(&sampledb->common.origin, NULL);
|
||||
|
||||
sampledb->common.magic = DNS_DB_MAGIC;
|
||||
sampledb->common.impmagic = SAMPLEDB_MAGIC;
|
||||
ISC_MAGIC_INIT(&sampledb->common, DNS_DB_MAGIC);
|
||||
ISC_IMPMAGIC_INIT(&sampledb->common, SAMPLEDB_MAGIC);
|
||||
|
||||
sampledb->common.methods = &sampledb_methods;
|
||||
sampledb->common.attributes = 0;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
@@
|
||||
identifier i;
|
||||
@@
|
||||
|
||||
struct i {
|
||||
...
|
||||
-isc_magic_t magic;
|
||||
+isc_magic_t magic;
|
||||
...
|
||||
};
|
||||
|
||||
@@
|
||||
identifier i;
|
||||
@@
|
||||
|
||||
struct i {
|
||||
-int magic;
|
||||
+isc_magic_t magic;
|
||||
...
|
||||
};
|
||||
|
||||
@@
|
||||
identifier o;
|
||||
@@
|
||||
|
||||
- o->magic = 0;
|
||||
+ ISC_MAGIC_CLEAR(o);
|
||||
|
||||
@@
|
||||
identifier o;
|
||||
expression M;
|
||||
@@
|
||||
|
||||
- o->magic = M;
|
||||
+ ISC_MAGIC_INIT(o, M);
|
||||
|
||||
@@
|
||||
identifier i;
|
||||
@@
|
||||
|
||||
struct i {
|
||||
...
|
||||
-unsigned int impmagic;
|
||||
+isc_magic_t impmagic;
|
||||
...
|
||||
};
|
||||
|
||||
@@
|
||||
identifier o;
|
||||
@@
|
||||
|
||||
- o->common.impmagic = 0;
|
||||
+ ISC_IMPMAGIC_CLEAR(&o->common);
|
||||
|
||||
@@
|
||||
identifier o;
|
||||
expression M;
|
||||
@@
|
||||
|
||||
- o->common.impmagic = M;
|
||||
+ ISC_IMPMAGIC_INIT(&o->common, M);
|
||||
|
||||
@@
|
||||
identifier o;
|
||||
@@
|
||||
|
||||
- o->common.magic = 0;
|
||||
+ ISC_MAGIC_CLEAR(&o->common);
|
||||
|
||||
@@
|
||||
identifier o;
|
||||
expression M;
|
||||
@@
|
||||
|
||||
- o->common.magic = M;
|
||||
+ ISC_MAGIC_INIT(&o->common, M);
|
||||
@@ -40,10 +40,10 @@ Implementation:
|
||||
|
||||
Types:
|
||||
struct dns_decompress {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
unsigned int allowed;
|
||||
int edns;
|
||||
dns_name_t owner_name;
|
||||
dns_name_t owner_name;
|
||||
unsigned int rdata;
|
||||
bool strict;
|
||||
}
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ Types:
|
||||
typedef struct dns_ixfr dns_ixfr_t;
|
||||
|
||||
struct dns_ixfr {
|
||||
unsigned int magic; /* IXFR */
|
||||
isc_magic_t magic; /* IXFR */
|
||||
uint32_t serial;
|
||||
time_t expire;
|
||||
unsigned int offset;
|
||||
@@ -129,7 +129,7 @@ Types:
|
||||
};
|
||||
|
||||
struct dns_zone {
|
||||
unsigned int magic; /* ZONE */
|
||||
isc_magic_t magic; /* ZONE */
|
||||
dns_name_t name;
|
||||
dns_rdataclass_t class;
|
||||
dns_zonetypes_t type;
|
||||
|
||||
+6
-9
@@ -321,7 +321,7 @@ code execution vulnerability.)
|
||||
#### <a name="magic"></a>Magic numbers
|
||||
|
||||
A number of data structures in the ISC and DNS libraries have an
|
||||
`unsigned int magic` value as the first field. The purpose of the
|
||||
`isc_magic_t magic` value as the first field. The purpose of the
|
||||
magic number is principally to validate that a pointer that's been
|
||||
passed to a subroutine really points to the type it claims to be. This
|
||||
helps detect problems caused by resources being freed prematurely, that
|
||||
@@ -332,14 +332,11 @@ Magic numbers should always be the first field in a structure. They never
|
||||
require locking to access. As to the actual value to be used, something
|
||||
mnemonic is good:
|
||||
|
||||
#define TASK_MAGIC 0x5441534BU /* TASK. */
|
||||
#define VALID_TASK(t) ((t) != NULL && \
|
||||
(t)->magic == TASK_MAGIC)
|
||||
#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K')
|
||||
#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC)
|
||||
|
||||
#define TASK_MANAGER_MAGIC 0x54534B4DU /* TSKM. */
|
||||
#define VALID_MANAGER(m) ((m) != NULL && \
|
||||
(m)->magic ==
|
||||
TASK_MANAGER_MAGIC)
|
||||
#define TASK_MANAGER_MAGIC ISC_MAGIC('T', 'S', 'K', 'M')
|
||||
#define VALID_MANAGER(m) ISC_MAGIC_VALID(m, TASK_MANAGER_MAGIC)
|
||||
|
||||
Unless the memory cost is critical, most objects should have a magic number.
|
||||
|
||||
@@ -595,7 +592,7 @@ an `ISC_LINK` as one of its members:
|
||||
|
||||
typedef struct isc_foo isc_foo_t;
|
||||
struct isc_foo {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
|
||||
/* other contents */
|
||||
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
|
||||
/*
|
||||
* Must set magic early because we use dns_acl_detach() to clean up.
|
||||
*/
|
||||
acl->magic = DNS_ACL_MAGIC;
|
||||
ISC_MAGIC_INIT(acl, DNS_ACL_MAGIC);
|
||||
|
||||
acl->elements = isc_mem_get(mctx, n * sizeof(dns_aclelement_t));
|
||||
acl->alloc = n;
|
||||
@@ -462,7 +462,7 @@ destroy(dns_acl_t *dacl) {
|
||||
if (dacl->iptable != NULL)
|
||||
dns_iptable_detach(&dacl->iptable);
|
||||
isc_refcount_destroy(&dacl->refcount);
|
||||
dacl->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dacl);
|
||||
isc_mem_putanddetach(&dacl->mctx, dacl, sizeof(*dacl));
|
||||
}
|
||||
|
||||
|
||||
+25
-25
@@ -94,7 +94,7 @@ typedef struct dns_adbfetch6 dns_adbfetch6_t;
|
||||
|
||||
/*% dns adb structure */
|
||||
struct dns_adb {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
|
||||
isc_mutex_t lock;
|
||||
isc_mutex_t reflock; /*%< Covers irefcnt, erefcnt */
|
||||
@@ -171,7 +171,7 @@ struct dns_adb {
|
||||
|
||||
/*% dns_adbname structure */
|
||||
struct dns_adbname {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_name_t name;
|
||||
dns_adb_t *adb;
|
||||
unsigned int partial_result;
|
||||
@@ -197,7 +197,7 @@ struct dns_adbname {
|
||||
|
||||
/*% The adbfetch structure */
|
||||
struct dns_adbfetch {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_fetch_t *fetch;
|
||||
dns_rdataset_t rdataset;
|
||||
unsigned int depth;
|
||||
@@ -209,7 +209,7 @@ struct dns_adbfetch {
|
||||
* namehook that will contain the next address this host has.
|
||||
*/
|
||||
struct dns_adbnamehook {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_adbentry_t *entry;
|
||||
ISC_LINK(dns_adbnamehook_t) plink;
|
||||
};
|
||||
@@ -220,7 +220,7 @@ struct dns_adbnamehook {
|
||||
* extended to other types of information about zones.
|
||||
*/
|
||||
struct dns_adblameinfo {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
|
||||
dns_name_t qname;
|
||||
dns_rdatatype_t qtype;
|
||||
@@ -235,7 +235,7 @@ struct dns_adblameinfo {
|
||||
* the host.
|
||||
*/
|
||||
struct dns_adbentry {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
|
||||
int lock_bucket;
|
||||
unsigned int refcnt;
|
||||
@@ -1674,7 +1674,7 @@ new_adbname(dns_adb_t *adb, const dns_name_t *dnsname) {
|
||||
return (NULL);
|
||||
}
|
||||
dns_name_init(&name->target, NULL);
|
||||
name->magic = DNS_ADBNAME_MAGIC;
|
||||
ISC_MAGIC_INIT(name, DNS_ADBNAME_MAGIC);
|
||||
name->adb = adb;
|
||||
name->partial_result = 0;
|
||||
name->flags = 0;
|
||||
@@ -1724,7 +1724,7 @@ free_adbname(dns_adb_t *adb, dns_adbname_t **name) {
|
||||
INSIST(n->lock_bucket == DNS_ADB_INVALIDBUCKET);
|
||||
INSIST(n->adb == adb);
|
||||
|
||||
n->magic = 0;
|
||||
ISC_MAGIC_CLEAR(n);
|
||||
dns_name_free(&n->name, adb->mctx);
|
||||
|
||||
isc_mempool_put(adb->nmp, n);
|
||||
@@ -1742,7 +1742,7 @@ new_adbnamehook(dns_adb_t *adb, dns_adbentry_t *entry) {
|
||||
if (nh == NULL)
|
||||
return (NULL);
|
||||
|
||||
nh->magic = DNS_ADBNAMEHOOK_MAGIC;
|
||||
ISC_MAGIC_INIT(nh, DNS_ADBNAMEHOOK_MAGIC);
|
||||
nh->entry = entry;
|
||||
ISC_LINK_INIT(nh, plink);
|
||||
|
||||
@@ -1760,7 +1760,7 @@ free_adbnamehook(dns_adb_t *adb, dns_adbnamehook_t **namehook) {
|
||||
INSIST(nh->entry == NULL);
|
||||
INSIST(!ISC_LINK_LINKED(nh, plink));
|
||||
|
||||
nh->magic = 0;
|
||||
ISC_MAGIC_CLEAR(nh);
|
||||
isc_mempool_put(adb->nhmp, nh);
|
||||
}
|
||||
|
||||
@@ -1779,7 +1779,7 @@ new_adblameinfo(dns_adb_t *adb, const dns_name_t *qname,
|
||||
isc_mempool_put(adb->limp, li);
|
||||
return (NULL);
|
||||
}
|
||||
li->magic = DNS_ADBLAMEINFO_MAGIC;
|
||||
ISC_MAGIC_INIT(li, DNS_ADBLAMEINFO_MAGIC);
|
||||
li->lame_timer = 0;
|
||||
li->qtype = qtype;
|
||||
ISC_LINK_INIT(li, plink);
|
||||
@@ -1799,7 +1799,7 @@ free_adblameinfo(dns_adb_t *adb, dns_adblameinfo_t **lameinfo) {
|
||||
|
||||
dns_name_free(&li->qname, adb->mctx);
|
||||
|
||||
li->magic = 0;
|
||||
ISC_MAGIC_CLEAR(li);
|
||||
|
||||
isc_mempool_put(adb->limp, li);
|
||||
}
|
||||
@@ -1812,7 +1812,7 @@ new_adbentry(dns_adb_t *adb) {
|
||||
if (e == NULL)
|
||||
return (NULL);
|
||||
|
||||
e->magic = DNS_ADBENTRY_MAGIC;
|
||||
ISC_MAGIC_INIT(e, DNS_ADBENTRY_MAGIC);
|
||||
e->lock_bucket = DNS_ADB_INVALIDBUCKET;
|
||||
e->refcnt = 0;
|
||||
e->nh = 0;
|
||||
@@ -1867,7 +1867,7 @@ free_adbentry(dns_adb_t *adb, dns_adbentry_t **entry) {
|
||||
INSIST(e->refcnt == 0);
|
||||
INSIST(!ISC_LINK_LINKED(e, plink));
|
||||
|
||||
e->magic = 0;
|
||||
ISC_MAGIC_CLEAR(e);
|
||||
|
||||
if (e->cookie != NULL)
|
||||
isc_mem_put(adb->mctx, e->cookie, e->cookielen);
|
||||
@@ -1897,7 +1897,7 @@ new_adbfind(dns_adb_t *adb) {
|
||||
/*
|
||||
* Public members.
|
||||
*/
|
||||
h->magic = 0;
|
||||
ISC_MAGIC_CLEAR(h);
|
||||
h->adb = adb;
|
||||
h->partial_result = 0;
|
||||
h->options = 0;
|
||||
@@ -1919,7 +1919,7 @@ new_adbfind(dns_adb_t *adb) {
|
||||
NULL, NULL, h);
|
||||
|
||||
inc_adb_irefcnt(adb);
|
||||
h->magic = DNS_ADBFIND_MAGIC;
|
||||
ISC_MAGIC_INIT(h, DNS_ADBFIND_MAGIC);
|
||||
return (h);
|
||||
}
|
||||
|
||||
@@ -1931,12 +1931,12 @@ new_adbfetch(dns_adb_t *adb) {
|
||||
if (f == NULL)
|
||||
return (NULL);
|
||||
|
||||
f->magic = 0;
|
||||
ISC_MAGIC_CLEAR(f);
|
||||
f->fetch = NULL;
|
||||
|
||||
dns_rdataset_init(&f->rdataset);
|
||||
|
||||
f->magic = DNS_ADBFETCH_MAGIC;
|
||||
ISC_MAGIC_INIT(f, DNS_ADBFETCH_MAGIC);
|
||||
|
||||
return (f);
|
||||
}
|
||||
@@ -1949,7 +1949,7 @@ free_adbfetch(dns_adb_t *adb, dns_adbfetch_t **fetch) {
|
||||
f = *fetch;
|
||||
*fetch = NULL;
|
||||
|
||||
f->magic = 0;
|
||||
ISC_MAGIC_CLEAR(f);
|
||||
|
||||
if (dns_rdataset_isassociated(&f->rdataset))
|
||||
dns_rdataset_disassociate(&f->rdataset);
|
||||
@@ -1971,7 +1971,7 @@ free_adbfind(dns_adb_t *adb, dns_adbfind_t **findp) {
|
||||
INSIST(find->name_bucket == DNS_ADB_INVALIDBUCKET);
|
||||
INSIST(find->adbname == NULL);
|
||||
|
||||
find->magic = 0;
|
||||
ISC_MAGIC_CLEAR(find);
|
||||
|
||||
isc_mutex_destroy(&find->lock);
|
||||
isc_mempool_put(adb->ahmp, find);
|
||||
@@ -1991,7 +1991,7 @@ new_adbaddrinfo(dns_adb_t *adb, dns_adbentry_t *entry, in_port_t port) {
|
||||
if (ai == NULL)
|
||||
return (NULL);
|
||||
|
||||
ai->magic = DNS_ADBADDRINFO_MAGIC;
|
||||
ISC_MAGIC_INIT(ai, DNS_ADBADDRINFO_MAGIC);
|
||||
ai->sockaddr = entry->sockaddr;
|
||||
isc_sockaddr_setport(&ai->sockaddr, port);
|
||||
ai->srtt = entry->srtt;
|
||||
@@ -2014,7 +2014,7 @@ free_adbaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **ainfo) {
|
||||
INSIST(ai->entry == NULL);
|
||||
INSIST(!ISC_LINK_LINKED(ai, publink));
|
||||
|
||||
ai->magic = 0;
|
||||
ISC_MAGIC_CLEAR(ai);
|
||||
|
||||
isc_mempool_put(adb->aimp, ai);
|
||||
}
|
||||
@@ -2455,7 +2455,7 @@ cleanup_entries(dns_adb_t *adb, int bucket, isc_stdtime_t now) {
|
||||
|
||||
static void
|
||||
destroy(dns_adb_t *adb) {
|
||||
adb->magic = 0;
|
||||
ISC_MAGIC_CLEAR(adb);
|
||||
|
||||
isc_task_detach(&adb->task);
|
||||
if (adb->excl != NULL)
|
||||
@@ -2530,7 +2530,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
* Initialize things here that cannot fail, and especially things
|
||||
* that must be NULL for the error return to work properly.
|
||||
*/
|
||||
adb->magic = 0;
|
||||
ISC_MAGIC_CLEAR(adb);
|
||||
adb->erefcnt = 1;
|
||||
adb->irefcnt = 0;
|
||||
adb->nmp = NULL;
|
||||
@@ -2696,7 +2696,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
/*
|
||||
* Normal return.
|
||||
*/
|
||||
adb->magic = DNS_ADB_MAGIC;
|
||||
ISC_MAGIC_INIT(adb, DNS_ADB_MAGIC);
|
||||
*newadb = adb;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@
|
||||
typedef struct dns_bcentry dns_bcentry_t;
|
||||
|
||||
struct dns_badcache {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
@@ -79,7 +79,7 @@ dns_badcache_init(isc_mem_t *mctx, unsigned int size, dns_badcache_t **bcp) {
|
||||
|
||||
bc->count = 0;
|
||||
bc->sweep = 0;
|
||||
bc->magic = BADCACHE_MAGIC;
|
||||
ISC_MAGIC_INIT(bc, BADCACHE_MAGIC);
|
||||
|
||||
*bcp = bc;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -94,7 +94,7 @@ dns_badcache_destroy(dns_badcache_t **bcp) {
|
||||
|
||||
dns_badcache_flush(bc);
|
||||
|
||||
bc->magic = 0;
|
||||
ISC_MAGIC_CLEAR(bc);
|
||||
isc_mutex_destroy(&bc->lock);
|
||||
isc_mem_put(bc->mctx, bc->table, sizeof(dns_bcentry_t *) * bc->size);
|
||||
isc_mem_putanddetach(&bc->mctx, bc, sizeof(dns_badcache_t));
|
||||
|
||||
+3
-3
@@ -92,7 +92,7 @@ dns_byaddr_createptrname(const isc_netaddr_t *address, unsigned int options,
|
||||
|
||||
struct dns_byaddr {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
isc_mutex_t lock;
|
||||
dns_fixedname_t name;
|
||||
@@ -229,7 +229,7 @@ dns_byaddr_create(isc_mem_t *mctx, const isc_netaddr_t *address,
|
||||
goto cleanup_lock;
|
||||
|
||||
byaddr->canceled = false;
|
||||
byaddr->magic = BYADDR_MAGIC;
|
||||
ISC_MAGIC_INIT(byaddr, BYADDR_MAGIC);
|
||||
|
||||
*byaddrp = byaddr;
|
||||
|
||||
@@ -276,7 +276,7 @@ dns_byaddr_destroy(dns_byaddr_t **byaddrp) {
|
||||
dns_lookup_destroy(&byaddr->lookup);
|
||||
|
||||
isc_mutex_destroy(&byaddr->lock);
|
||||
byaddr->magic = 0;
|
||||
ISC_MAGIC_CLEAR(byaddr);
|
||||
isc_mem_putanddetach(&byaddr->mctx, byaddr, sizeof(*byaddr));
|
||||
|
||||
*byaddrp = NULL;
|
||||
|
||||
+3
-3
@@ -125,7 +125,7 @@ struct cache_cleaner {
|
||||
|
||||
struct dns_cache {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
isc_mutex_t filelock;
|
||||
isc_mem_t *mctx; /* Main cache memory */
|
||||
@@ -267,7 +267,7 @@ dns_cache_create(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr,
|
||||
|
||||
cache->filename = NULL;
|
||||
|
||||
cache->magic = CACHE_MAGIC;
|
||||
ISC_MAGIC_INIT(cache, CACHE_MAGIC);
|
||||
|
||||
/*
|
||||
* RBT-type cache DB has its own mechanism of cache cleaning and doesn't
|
||||
@@ -384,7 +384,7 @@ cache_free(dns_cache_t *cache) {
|
||||
isc_mutex_destroy(&cache->lock);
|
||||
isc_mutex_destroy(&cache->filelock);
|
||||
|
||||
cache->magic = 0;
|
||||
ISC_MAGIC_CLEAR(cache);
|
||||
isc_mem_detach(&cache->hmctx);
|
||||
isc_mem_putanddetach(&cache->mctx, cache, sizeof(*cache));
|
||||
}
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ static void
|
||||
dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t *callbacks) {
|
||||
REQUIRE(callbacks != NULL);
|
||||
|
||||
callbacks->magic = DNS_CALLBACK_MAGIC;
|
||||
ISC_MAGIC_INIT(callbacks, DNS_CALLBACK_MAGIC);
|
||||
callbacks->add = NULL;
|
||||
callbacks->rawdata = NULL;
|
||||
callbacks->zone = NULL;
|
||||
|
||||
+9
-9
@@ -42,7 +42,7 @@
|
||||
* Single member zone in a catalog
|
||||
*/
|
||||
struct dns_catz_entry {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_name_t name;
|
||||
dns_catz_options_t opts;
|
||||
isc_refcount_t refs;
|
||||
@@ -52,7 +52,7 @@ struct dns_catz_entry {
|
||||
* Catalog zone
|
||||
*/
|
||||
struct dns_catz_zone {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_name_t name;
|
||||
dns_catz_zones_t *catzs;
|
||||
dns_rdata_t soa;
|
||||
@@ -91,7 +91,7 @@ catz_process_zones_suboption(dns_catz_zone_t *zone, dns_rdataset_t *value,
|
||||
* Collection of catalog zones for a view
|
||||
*/
|
||||
struct dns_catz_zones {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_ht_t *zones;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t refs;
|
||||
@@ -216,7 +216,7 @@ dns_catz_entry_new(isc_mem_t *mctx, const dns_name_t *domain,
|
||||
|
||||
dns_catz_options_init(&nentry->opts);
|
||||
isc_refcount_init(&nentry->refs, 1);
|
||||
nentry->magic = DNS_CATZ_ENTRY_MAGIC;
|
||||
ISC_MAGIC_INIT(nentry, DNS_CATZ_ENTRY_MAGIC);
|
||||
*nentryp = nentry;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
@@ -277,7 +277,7 @@ dns_catz_entry_detach(dns_catz_zone_t *zone, dns_catz_entry_t **entryp) {
|
||||
|
||||
if (isc_refcount_decrement(&entry->refs) == 1) {
|
||||
isc_mem_t *mctx = zone->catzs->mctx;
|
||||
entry->magic = 0;
|
||||
ISC_MAGIC_CLEAR(entry);
|
||||
isc_refcount_destroy(&entry->refs);
|
||||
dns_catz_options_free(&entry->opts, mctx);
|
||||
if (dns_name_dynamic(&entry->name))
|
||||
@@ -609,7 +609,7 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
||||
result = isc_task_create(taskmgr, 0, &new_zones->updater);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_ht;
|
||||
new_zones->magic = DNS_CATZ_ZONES_MAGIC;
|
||||
ISC_MAGIC_INIT(new_zones, DNS_CATZ_ZONES_MAGIC);
|
||||
|
||||
*catzsp = new_zones;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -678,7 +678,7 @@ dns_catz_new_zone(dns_catz_zones_t *catzs, dns_catz_zone_t **zonep,
|
||||
new_zone->db_registered = false;
|
||||
new_zone->version = (uint32_t)(-1);
|
||||
isc_refcount_init(&new_zone->refs, 1);
|
||||
new_zone->magic = DNS_CATZ_ZONE_MAGIC;
|
||||
ISC_MAGIC_INIT(new_zone, DNS_CATZ_ZONE_MAGIC);
|
||||
|
||||
*zonep = new_zone;
|
||||
|
||||
@@ -803,7 +803,7 @@ dns_catz_zone_detach(dns_catz_zone_t **zonep) {
|
||||
INSIST(isc_ht_count(zone->entries) == 0);
|
||||
isc_ht_destroy(&zone->entries);
|
||||
}
|
||||
zone->magic = 0;
|
||||
ISC_MAGIC_CLEAR(zone);
|
||||
isc_timer_detach(&zone->updatetimer);
|
||||
if (zone->db_registered == true) {
|
||||
INSIST(dns_db_updatenotify_unregister(
|
||||
@@ -837,7 +837,7 @@ dns_catz_catzs_detach(dns_catz_zones_t **catzsp) {
|
||||
*catzsp = NULL;
|
||||
|
||||
if (isc_refcount_decrement(&catzs->refs) == 1) {
|
||||
catzs->magic = 0;
|
||||
ISC_MAGIC_CLEAR(catzs);
|
||||
isc_task_destroy(&catzs->updater);
|
||||
isc_mutex_destroy(&catzs->lock);
|
||||
if (catzs->zones != NULL) {
|
||||
|
||||
+13
-13
@@ -81,7 +81,7 @@
|
||||
*/
|
||||
struct dns_client {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
unsigned int attributes;
|
||||
isc_mutex_t lock;
|
||||
isc_mem_t *mctx;
|
||||
@@ -127,7 +127,7 @@ struct dns_client {
|
||||
*/
|
||||
typedef struct resctx {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
dns_client_t *client;
|
||||
bool want_dnssec;
|
||||
@@ -173,7 +173,7 @@ typedef struct resarg {
|
||||
*/
|
||||
typedef struct reqctx {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
dns_client_t *client;
|
||||
unsigned int parseoptions;
|
||||
@@ -221,7 +221,7 @@ typedef struct updatearg {
|
||||
*/
|
||||
typedef struct updatectx {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
dns_client_t *client;
|
||||
bool want_tcp;
|
||||
@@ -574,7 +574,7 @@ dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
client->find_udpretries = DEF_FIND_UDPRETRIES;
|
||||
client->attributes = 0;
|
||||
|
||||
client->magic = DNS_CLIENT_MAGIC;
|
||||
ISC_MAGIC_INIT(client, DNS_CLIENT_MAGIC);
|
||||
|
||||
*clientp = client;
|
||||
|
||||
@@ -634,7 +634,7 @@ destroyclient(dns_client_t *client) {
|
||||
}
|
||||
|
||||
isc_mutex_destroy(&client->lock);
|
||||
client->magic = 0;
|
||||
ISC_MAGIC_CLEAR(client);
|
||||
|
||||
isc_mem_putanddetach(&client->mctx, client, sizeof(*client));
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
|
||||
ISC_LIST_INIT(rctx->namelist);
|
||||
rctx->event = event;
|
||||
|
||||
rctx->magic = RCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(rctx, RCTX_MAGIC);
|
||||
isc_refcount_increment(&client->references);
|
||||
|
||||
LOCK(&client->lock);
|
||||
@@ -1479,7 +1479,7 @@ dns_client_destroyrestrans(dns_clientrestrans_t **transp) {
|
||||
INSIST(ISC_LIST_EMPTY(rctx->namelist));
|
||||
|
||||
isc_mutex_destroy(&rctx->lock);
|
||||
rctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(rctx);
|
||||
|
||||
isc_mem_put(mctx, rctx, sizeof(*rctx));
|
||||
|
||||
@@ -1769,7 +1769,7 @@ dns_client_startrequest(dns_client_t *client, dns_message_t *qmessage,
|
||||
if (tsec != NULL)
|
||||
dns_tsec_getkey(tsec, &ctx->tsigkey);
|
||||
|
||||
ctx->magic = REQCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(ctx, REQCTX_MAGIC);
|
||||
|
||||
LOCK(&client->lock);
|
||||
ISC_LIST_APPEND(client->reqctxs, ctx, link);
|
||||
@@ -1851,7 +1851,7 @@ dns_client_destroyreqtrans(dns_clientreqtrans_t **transp) {
|
||||
UNLOCK(&client->lock);
|
||||
|
||||
isc_mutex_destroy(&ctx->lock);
|
||||
ctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(ctx);
|
||||
|
||||
isc_mem_put(mctx, ctx, sizeof(*ctx));
|
||||
|
||||
@@ -2914,7 +2914,7 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
|
||||
goto fail;
|
||||
dns_message_currentname(uctx->updatemsg, section, &uctx->firstname);
|
||||
|
||||
uctx->magic = UCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(uctx, UCTX_MAGIC);
|
||||
|
||||
LOCK(&client->lock);
|
||||
ISC_LIST_APPEND(client->updatectxs, uctx, link);
|
||||
@@ -2956,7 +2956,7 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
|
||||
dns_tsigkey_detach(&uctx->tsigkey);
|
||||
isc_task_detach(&tclone);
|
||||
isc_mutex_destroy(&uctx->lock);
|
||||
uctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(uctx);
|
||||
isc_mem_put(client->mctx, uctx, sizeof(*uctx));
|
||||
dns_view_detach(&view);
|
||||
|
||||
@@ -3021,7 +3021,7 @@ dns_client_destroyupdatetrans(dns_clientupdatetrans_t **transp) {
|
||||
UNLOCK(&client->lock);
|
||||
|
||||
isc_mutex_destroy(&uctx->lock);
|
||||
uctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(uctx);
|
||||
|
||||
isc_mem_put(mctx, uctx, sizeof(*uctx));
|
||||
|
||||
|
||||
+4
-4
@@ -152,7 +152,7 @@ dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx) {
|
||||
|
||||
memset(&cctx->table[0], 0, sizeof(cctx->table));
|
||||
|
||||
cctx->magic = CCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(cctx, CCTX_MAGIC);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ dns_compress_invalidate(dns_compress_t *cctx) {
|
||||
}
|
||||
}
|
||||
|
||||
cctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(cctx);
|
||||
cctx->allowed = 0;
|
||||
cctx->edns = -1;
|
||||
}
|
||||
@@ -511,7 +511,7 @@ dns_decompress_init(dns_decompress_t *dctx, int edns,
|
||||
dctx->allowed = DNS_COMPRESS_NONE;
|
||||
dctx->edns = edns;
|
||||
dctx->type = type;
|
||||
dctx->magic = DCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(dctx, DCTX_MAGIC);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -519,7 +519,7 @@ dns_decompress_invalidate(dns_decompress_t *dctx) {
|
||||
|
||||
REQUIRE(VALID_DCTX(dctx));
|
||||
|
||||
dctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dctx);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@
|
||||
|
||||
struct dns_dbtable {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
dns_rdataclass_t rdclass;
|
||||
isc_rwlock_t tree_lock;
|
||||
@@ -70,7 +70,7 @@ dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
dbtable->mctx = NULL;
|
||||
isc_mem_attach(mctx, &dbtable->mctx);
|
||||
dbtable->rdclass = rdclass;
|
||||
dbtable->magic = DBTABLE_MAGIC;
|
||||
ISC_MAGIC_INIT(dbtable, DBTABLE_MAGIC);
|
||||
isc_refcount_init(&dbtable->references, 1);
|
||||
|
||||
*dbtablep = dbtable;
|
||||
@@ -103,7 +103,7 @@ dbtable_free(dns_dbtable_t *dbtable) {
|
||||
|
||||
isc_rwlock_destroy(&dbtable->tree_lock);
|
||||
|
||||
dbtable->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dbtable);
|
||||
|
||||
isc_mem_putanddetach(&dbtable->mctx, dbtable, sizeof(*dbtable));
|
||||
}
|
||||
|
||||
+3
-3
@@ -93,7 +93,7 @@ dns_difftuple_create(isc_mem_t *mctx,
|
||||
|
||||
ISC_LINK_INIT(&t->rdata, link);
|
||||
ISC_LINK_INIT(t, link);
|
||||
t->magic = DNS_DIFFTUPLE_MAGIC;
|
||||
ISC_MAGIC_INIT(t, DNS_DIFFTUPLE_MAGIC);
|
||||
|
||||
INSIST(datap == (unsigned char *)t + size);
|
||||
|
||||
@@ -109,7 +109,7 @@ dns_difftuple_free(dns_difftuple_t **tp) {
|
||||
REQUIRE(DNS_DIFFTUPLE_VALID(t));
|
||||
|
||||
dns_name_invalidate(&t->name);
|
||||
t->magic = 0;
|
||||
ISC_MAGIC_CLEAR(t);
|
||||
mctx = t->mctx;
|
||||
isc_mem_free(mctx, t);
|
||||
isc_mem_detach(&mctx);
|
||||
@@ -126,7 +126,7 @@ void
|
||||
dns_diff_init(isc_mem_t *mctx, dns_diff_t *diff) {
|
||||
diff->mctx = mctx;
|
||||
ISC_LIST_INIT(diff->tuples);
|
||||
diff->magic = DNS_DIFF_MAGIC;
|
||||
ISC_MAGIC_INIT(diff, DNS_DIFF_MAGIC);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+16
-16
@@ -50,7 +50,7 @@ typedef struct dispportentry dispportentry_t;
|
||||
typedef ISC_LIST(dispportentry_t) dispportlist_t;
|
||||
|
||||
typedef struct dns_qid {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
unsigned int qid_nbuckets; /*%< hash table size */
|
||||
unsigned int qid_increment; /*%< id increment on collision */
|
||||
isc_mutex_t lock;
|
||||
@@ -60,7 +60,7 @@ typedef struct dns_qid {
|
||||
|
||||
struct dns_dispatchmgr {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_acl_t *blackhole;
|
||||
dns_portlist_t *portlist;
|
||||
@@ -117,7 +117,7 @@ struct dns_dispatchmgr {
|
||||
#define IS_PRIVATE(d) (((d)->attributes & DNS_DISPATCHATTR_PRIVATE) != 0)
|
||||
|
||||
struct dns_dispentry {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_dispatch_t *disp;
|
||||
dns_messageid_t id;
|
||||
in_port_t port;
|
||||
@@ -154,7 +154,7 @@ struct dns_dispentry {
|
||||
#endif
|
||||
|
||||
struct dispsocket {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_socket_t *socket;
|
||||
dns_dispatch_t *disp;
|
||||
isc_sockaddr_t host;
|
||||
@@ -193,7 +193,7 @@ struct dispportentry {
|
||||
|
||||
struct dns_dispatch {
|
||||
/* Unlocked. */
|
||||
unsigned int magic; /*%< magic */
|
||||
isc_magic_t magic; /*%< magic */
|
||||
dns_dispatchmgr_t *mgr; /*%< dispatch manager */
|
||||
int ntasks;
|
||||
/*%
|
||||
@@ -699,7 +699,7 @@ get_dispsocket(dns_dispatch_t *disp, const isc_sockaddr_t *dest,
|
||||
&dispsock->task);
|
||||
ISC_LINK_INIT(dispsock, link);
|
||||
ISC_LINK_INIT(dispsock, blink);
|
||||
dispsock->magic = DISPSOCK_MAGIC;
|
||||
ISC_MAGIC_INIT(dispsock, DISPSOCK_MAGIC);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -790,7 +790,7 @@ destroy_dispsocket(dns_dispatch_t *disp, dispsocket_t **dispsockp) {
|
||||
REQUIRE(!ISC_LINK_LINKED(dispsock, link));
|
||||
|
||||
disp->nsockets--;
|
||||
dispsock->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dispsock);
|
||||
if (dispsock->portentry != NULL)
|
||||
deref_portentry(disp, &dispsock->portentry);
|
||||
if (dispsock->socket != NULL)
|
||||
@@ -1616,7 +1616,7 @@ destroy_mgr(dns_dispatchmgr_t **mgrp) {
|
||||
mgr = *mgrp;
|
||||
*mgrp = NULL;
|
||||
|
||||
mgr->magic = 0;
|
||||
ISC_MAGIC_CLEAR(mgr);
|
||||
isc_mutex_destroy(&mgr->lock);
|
||||
mgr->state = 0;
|
||||
|
||||
@@ -1811,7 +1811,7 @@ dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp)
|
||||
mgr->v6ports = NULL;
|
||||
mgr->nv4ports = 0;
|
||||
mgr->nv6ports = 0;
|
||||
mgr->magic = DNS_DISPATCHMGR_MAGIC;
|
||||
ISC_MAGIC_INIT(mgr, DNS_DISPATCHMGR_MAGIC);
|
||||
|
||||
result = create_default_portset(mctx, &v4portset);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
@@ -2243,7 +2243,7 @@ qid_allocate(dns_dispatchmgr_t *mgr, unsigned int buckets,
|
||||
|
||||
qid->qid_nbuckets = buckets;
|
||||
qid->qid_increment = increment;
|
||||
qid->magic = QID_MAGIC;
|
||||
ISC_MAGIC_INIT(qid, QID_MAGIC);
|
||||
*qidp = qid;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -2258,7 +2258,7 @@ qid_destroy(isc_mem_t *mctx, dns_qid_t **qidp) {
|
||||
REQUIRE(VALID_QID(qid));
|
||||
|
||||
*qidp = NULL;
|
||||
qid->magic = 0;
|
||||
ISC_MAGIC_CLEAR(qid);
|
||||
isc_mem_put(mctx, qid->qid_table,
|
||||
qid->qid_nbuckets * sizeof(dns_displist_t));
|
||||
if (qid->sock_table != NULL) {
|
||||
@@ -2291,7 +2291,7 @@ dispatch_allocate(dns_dispatchmgr_t *mgr, unsigned int maxrequests,
|
||||
if (disp == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
disp->magic = 0;
|
||||
ISC_MAGIC_CLEAR(disp);
|
||||
disp->mgr = mgr;
|
||||
disp->maxrequests = maxrequests;
|
||||
disp->attributes = 0;
|
||||
@@ -2324,7 +2324,7 @@ dispatch_allocate(dns_dispatchmgr_t *mgr, unsigned int maxrequests,
|
||||
goto kill_lock;
|
||||
}
|
||||
|
||||
disp->magic = DISPATCH_MAGIC;
|
||||
ISC_MAGIC_INIT(disp, DISPATCH_MAGIC);
|
||||
|
||||
*dispp = disp;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -2386,7 +2386,7 @@ dispatch_free(dns_dispatch_t **dispp) {
|
||||
|
||||
disp->mgr = NULL;
|
||||
isc_mutex_destroy(&disp->lock);
|
||||
disp->magic = 0;
|
||||
ISC_MAGIC_CLEAR(disp);
|
||||
isc_mempool_put(mgr->dpool, disp);
|
||||
}
|
||||
|
||||
@@ -3146,7 +3146,7 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options,
|
||||
res->item_out = false;
|
||||
ISC_LIST_INIT(res->items);
|
||||
ISC_LINK_INIT(res, link);
|
||||
res->magic = RESPONSE_MAGIC;
|
||||
ISC_MAGIC_INIT(res, RESPONSE_MAGIC);
|
||||
|
||||
LOCK(&qid->lock);
|
||||
ISC_LIST_APPEND(qid->qid_table[bucket], res, link);
|
||||
@@ -3363,7 +3363,7 @@ dns_dispatch_removeresponse(dns_dispentry_t **resp,
|
||||
free_devent(disp, ev);
|
||||
ev = ISC_LIST_HEAD(res->items);
|
||||
}
|
||||
res->magic = 0;
|
||||
ISC_MAGIC_CLEAR(res);
|
||||
isc_mempool_put(disp->mgr->rpool, res);
|
||||
if (disp->shutting_down == 1)
|
||||
do_cancel(disp);
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
|
||||
/* mark the DLZ driver as valid */
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
RWUNLOCK(&dlz_implock, isc_rwlocktype_read);
|
||||
db->magic = DNS_DLZ_MAGIC;
|
||||
ISC_MAGIC_INIT(db, DNS_DLZ_MAGIC);
|
||||
isc_mem_attach(mctx, &db->mctx);
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(2),
|
||||
|
||||
+4
-4
@@ -263,8 +263,8 @@ dns_dnsrps_rewrite_init(librpz_emsg_t *emsg, dns_rpz_st_t *st,
|
||||
return (DNS_R_DISALLOWED);
|
||||
}
|
||||
|
||||
rpsdb->common.magic = DNS_DB_MAGIC;
|
||||
rpsdb->common.impmagic = RPSDB_MAGIC;
|
||||
ISC_MAGIC_INIT(&rpsdb->common, DNS_DB_MAGIC);
|
||||
ISC_IMPMAGIC_INIT(&rpsdb->common, RPSDB_MAGIC);
|
||||
rpsdb->common.methods = &rpsdb_db_methods;
|
||||
rpsdb->common.rdclass = dns_rdataclass_in;
|
||||
dns_name_init(&rpsdb->common.origin, NULL);
|
||||
@@ -381,7 +381,7 @@ rpsdb_detach(dns_db_t **dbp) {
|
||||
return;
|
||||
|
||||
librpz->rsp_detach(&rpsdb->rsp);
|
||||
rpsdb->common.impmagic = 0;
|
||||
ISC_IMPMAGIC_CLEAR(&rpsdb->common);
|
||||
isc_mem_putanddetach(&rpsdb->common.mctx, rpsdb, sizeof(*rpsdb));
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ rpsdb_allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
rpsdb_iter = isc_mem_get(rpsdb->common.mctx, sizeof(*rpsdb_iter));
|
||||
|
||||
memset(rpsdb_iter, 0, sizeof(*rpsdb_iter));
|
||||
rpsdb_iter->common.magic = DNS_RDATASETITER_MAGIC;
|
||||
ISC_MAGIC_INIT(&rpsdb_iter->common, DNS_RDATASETITER_MAGIC);
|
||||
rpsdb_iter->common.methods = &rpsdb_rdatasetiter_methods;
|
||||
rpsdb_iter->common.db = db;
|
||||
rpsdb_attachnode(db, node, &rpsdb_iter->common.node);
|
||||
|
||||
+3
-3
@@ -99,7 +99,7 @@ struct dns_dthandle {
|
||||
};
|
||||
|
||||
struct dns_dtenv {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_refcount_t refcount;
|
||||
|
||||
isc_mem_t *mctx;
|
||||
@@ -262,7 +262,7 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
||||
env->fopt = *foptp;
|
||||
*foptp = NULL;
|
||||
|
||||
env->magic = DTENV_MAGIC;
|
||||
ISC_MAGIC_INIT(env, DTENV_MAGIC);
|
||||
*envp = env;
|
||||
|
||||
cleanup:
|
||||
@@ -545,7 +545,7 @@ destroy(dns_dtenv_t *env) {
|
||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DNSTAP,
|
||||
DNS_LOGMODULE_DNSTAP, ISC_LOG_INFO,
|
||||
"closing dnstap");
|
||||
env->magic = 0;
|
||||
ISC_MAGIC_CLEAR(env);
|
||||
|
||||
generation++;
|
||||
|
||||
|
||||
+3
-3
@@ -341,7 +341,7 @@ dst_context_create(dst_key_t *key, isc_mem_t *mctx,
|
||||
isc_mem_putanddetach(&dctx->mctx, dctx, sizeof(dst_context_t));
|
||||
return (result);
|
||||
}
|
||||
dctx->magic = CTX_MAGIC;
|
||||
ISC_MAGIC_INIT(dctx, CTX_MAGIC);
|
||||
*dctxp = dctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ dst_context_destroy(dst_context_t **dctxp) {
|
||||
dctx->key->func->destroyctx(dctx);
|
||||
if (dctx->key != NULL)
|
||||
dst_key_free(&dctx->key);
|
||||
dctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dctx);
|
||||
isc_mem_putanddetach(&dctx->mctx, dctx, sizeof(dst_context_t));
|
||||
*dctxp = NULL;
|
||||
}
|
||||
@@ -1484,7 +1484,7 @@ get_key_struct(const dns_name_t *name, unsigned int alg,
|
||||
key->timeset[i] = false;
|
||||
}
|
||||
key->inactive = false;
|
||||
key->magic = KEY_MAGIC;
|
||||
ISC_MAGIC_INIT(key, KEY_MAGIC);
|
||||
return (key);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ typedef enum { DO_SIGN, DO_VERIFY } dst_use_t;
|
||||
|
||||
/*% DST Key Structure */
|
||||
struct dst_key {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_refcount_t refs;
|
||||
dns_name_t * key_name; /*%< name of the key */
|
||||
unsigned int key_size; /*%< size of the key in bits */
|
||||
@@ -129,7 +129,7 @@ struct dst_key {
|
||||
};
|
||||
|
||||
struct dst_context {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dst_use_t use;
|
||||
dst_key_t *key;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
+2
-2
@@ -425,7 +425,7 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
||||
dctx->refvar = &isc_bind9;
|
||||
|
||||
isc_mem_attach(mctx, &dctx->mctx);
|
||||
dctx->magic = DNS_DYNDBCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(dctx, DNS_DYNDBCTX_MAGIC);
|
||||
|
||||
*dctxp = dctx;
|
||||
|
||||
@@ -441,7 +441,7 @@ dns_dyndb_destroyctx(dns_dyndbctx_t **dctxp) {
|
||||
dctx = *dctxp;
|
||||
*dctxp = NULL;
|
||||
|
||||
dctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dctx);
|
||||
|
||||
if (dctx->view != NULL)
|
||||
dns_view_detach(&dctx->view);
|
||||
|
||||
+8
-8
@@ -53,7 +53,7 @@ typedef struct dns_ecdb {
|
||||
|
||||
typedef struct dns_ecdbnode {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
dns_ecdb_t *ecdb;
|
||||
dns_name_t name;
|
||||
@@ -179,8 +179,8 @@ destroy_ecdb(dns_ecdb_t *ecdb) {
|
||||
|
||||
isc_mutex_destroy(&ecdb->lock);
|
||||
|
||||
ecdb->common.impmagic = 0;
|
||||
ecdb->common.magic = 0;
|
||||
ISC_IMPMAGIC_CLEAR(&ecdb->common);
|
||||
ISC_MAGIC_CLEAR(&ecdb->common);
|
||||
|
||||
isc_mem_putanddetach(&ecdb->common.mctx, ecdb, sizeof(*ecdb));
|
||||
}
|
||||
@@ -240,7 +240,7 @@ destroynode(dns_ecdbnode_t *node) {
|
||||
isc_mutex_destroy(&node->lock);
|
||||
isc_refcount_destroy(&node->references);
|
||||
|
||||
node->magic = 0;
|
||||
ISC_MAGIC_CLEAR(node);
|
||||
isc_mem_put(mctx, node, sizeof(*node));
|
||||
|
||||
destroy_ecdb(ecdb);
|
||||
@@ -352,7 +352,7 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create,
|
||||
ISC_LIST_APPEND(ecdb->nodes, node, link);
|
||||
UNLOCK(&ecdb->lock);
|
||||
|
||||
node->magic = ECDBNODE_MAGIC;
|
||||
ISC_MAGIC_INIT(node, ECDBNODE_MAGIC);
|
||||
|
||||
*nodep = node;
|
||||
|
||||
@@ -499,7 +499,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
|
||||
iterator = isc_mem_get(mctx, sizeof(ecdb_rdatasetiter_t));
|
||||
|
||||
iterator->common.magic = DNS_RDATASETITER_MAGIC;
|
||||
ISC_MAGIC_INIT(&iterator->common, DNS_RDATASETITER_MAGIC);
|
||||
iterator->common.methods = &rdatasetiter_methods;
|
||||
iterator->common.db = db;
|
||||
iterator->common.node = NULL;
|
||||
@@ -599,8 +599,8 @@ dns_ecdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
|
||||
ecdb->common.mctx = NULL;
|
||||
isc_mem_attach(mctx, &ecdb->common.mctx);
|
||||
ecdb->common.impmagic = ECDB_MAGIC;
|
||||
ecdb->common.magic = DNS_DB_MAGIC;
|
||||
ISC_IMPMAGIC_INIT(&ecdb->common, ECDB_MAGIC);
|
||||
ISC_MAGIC_INIT(&ecdb->common, DNS_DB_MAGIC);
|
||||
|
||||
*dbp = (dns_db_t *)ecdb;
|
||||
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@
|
||||
|
||||
struct dns_fwdtable {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_rwlock_t rwlock;
|
||||
/* Locked by lock. */
|
||||
@@ -56,7 +56,7 @@ dns_fwdtable_create(isc_mem_t *mctx, dns_fwdtable_t **fwdtablep) {
|
||||
|
||||
fwdtable->mctx = NULL;
|
||||
isc_mem_attach(mctx, &fwdtable->mctx);
|
||||
fwdtable->magic = FWDTABLEMAGIC;
|
||||
ISC_MAGIC_INIT(fwdtable, FWDTABLEMAGIC);
|
||||
*fwdtablep = fwdtable;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -204,7 +204,7 @@ dns_fwdtable_destroy(dns_fwdtable_t **fwdtablep) {
|
||||
|
||||
dns_rbt_destroy(&fwdtable->table);
|
||||
isc_rwlock_destroy(&fwdtable->rwlock);
|
||||
fwdtable->magic = 0;
|
||||
ISC_MAGIC_CLEAR(fwdtable);
|
||||
|
||||
isc_mem_putanddetach(&fwdtable->mctx, fwdtable, sizeof(dns_fwdtable_t));
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ struct dns_aclelement {
|
||||
};
|
||||
|
||||
struct dns_acl {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t refcount;
|
||||
dns_iptable_t *iptable;
|
||||
|
||||
@@ -105,7 +105,7 @@ typedef struct dns_adbname dns_adbname_t;
|
||||
*/
|
||||
struct dns_adbfind {
|
||||
/* Public */
|
||||
unsigned int magic; /*%< RO: magic */
|
||||
isc_magic_t magic; /*%< RO: magic */
|
||||
dns_adbaddrinfolist_t list; /*%< RO: list of addrs */
|
||||
unsigned int query_pending; /*%< RO: partial list */
|
||||
unsigned int partial_result; /*%< RO: addrs missing */
|
||||
@@ -212,7 +212,7 @@ struct dns_adbfind {
|
||||
* The answers to queries come back as a list of these.
|
||||
*/
|
||||
struct dns_adbaddrinfo {
|
||||
unsigned int magic; /*%< private */
|
||||
isc_magic_t magic; /*%< private */
|
||||
|
||||
isc_sockaddr_t sockaddr; /*%< [rw] */
|
||||
unsigned int srtt; /*%< [rw] microsecs */
|
||||
|
||||
@@ -34,7 +34,7 @@ ISC_LANG_BEGINDECLS
|
||||
#define DNS_CALLBACK_VALID(cb) ISC_MAGIC_VALID(cb, DNS_CALLBACK_MAGIC)
|
||||
|
||||
struct dns_rdatacallbacks {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
|
||||
/*%
|
||||
* dns_load_master calls this when it has rdatasets to commit.
|
||||
|
||||
@@ -64,7 +64,7 @@ struct dns_compressnode {
|
||||
};
|
||||
|
||||
struct dns_compress {
|
||||
unsigned int magic; /*%< Magic number. */
|
||||
isc_magic_t magic; /*%< Magic number. */
|
||||
unsigned int allowed; /*%< Allowed methods. */
|
||||
int edns; /*%< Edns version or -1. */
|
||||
/*% Global compression table. */
|
||||
@@ -82,7 +82,7 @@ typedef enum {
|
||||
} dns_decompresstype_t;
|
||||
|
||||
struct dns_decompress {
|
||||
unsigned int magic; /*%< Magic number. */
|
||||
isc_magic_t magic; /*%< Magic number. */
|
||||
unsigned int allowed; /*%< Allowed methods. */
|
||||
int edns; /*%< Edns version or -1. */
|
||||
dns_decompresstype_t type; /*%< Strict checking */
|
||||
|
||||
@@ -221,8 +221,8 @@ typedef isc_result_t
|
||||
* invariants.
|
||||
*/
|
||||
struct dns_db {
|
||||
unsigned int magic;
|
||||
unsigned int impmagic;
|
||||
isc_magic_t magic;
|
||||
isc_magic_t impmagic;
|
||||
dns_dbmethods_t * methods;
|
||||
uint16_t attributes;
|
||||
dns_rdataclass_t rdclass;
|
||||
|
||||
@@ -96,7 +96,7 @@ typedef struct dns_dbiteratormethods {
|
||||
*/
|
||||
struct dns_dbiterator {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_dbiteratormethods_t * methods;
|
||||
dns_db_t * db;
|
||||
bool relative_names;
|
||||
|
||||
@@ -72,7 +72,7 @@ typedef struct dns_difftuple dns_difftuple_t;
|
||||
#define DNS_DIFFTUPLE_VALID(t) ISC_MAGIC_VALID(t, DNS_DIFFTUPLE_MAGIC)
|
||||
|
||||
struct dns_difftuple {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_diffop_t op;
|
||||
dns_name_t name;
|
||||
@@ -93,7 +93,7 @@ typedef struct dns_diff dns_diff_t;
|
||||
#define DNS_DIFF_VALID(t) ISC_MAGIC_VALID(t, DNS_DIFF_MAGIC)
|
||||
|
||||
struct dns_diff {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
ISC_LIST(dns_difftuple_t) tuples;
|
||||
};
|
||||
|
||||
@@ -212,7 +212,7 @@ typedef isc_result_t (*dlzconfigure_callback_t)(dns_view_t *, dns_dlzdb_t *,
|
||||
|
||||
/*% An instance of a DLZ driver */
|
||||
struct dns_dlzdb {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_dlzimplementation_t *implementation;
|
||||
void *dbdata;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isc/magic.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#include <dns/types.h>
|
||||
@@ -32,7 +33,7 @@ ISC_LANG_BEGINDECLS
|
||||
* function should detach from them.
|
||||
*/
|
||||
struct dns_dyndbctx {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
const void *hashinit;
|
||||
isc_mem_t *mctx;
|
||||
isc_log_t *lctx;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <dns/types.h>
|
||||
|
||||
struct dns_iptable {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t refcount;
|
||||
isc_radix_tree_t *radix;
|
||||
|
||||
@@ -52,7 +52,7 @@ struct dns_kasp_key {
|
||||
|
||||
/* Stores a DNSSEC policy */
|
||||
struct dns_kasp {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t* mctx;
|
||||
char* name;
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ struct dns_sortlist_arg {
|
||||
|
||||
struct dns_message {
|
||||
/* public from here down */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
|
||||
dns_messageid_t id;
|
||||
unsigned int flags;
|
||||
|
||||
@@ -102,7 +102,7 @@ ISC_LANG_BEGINDECLS
|
||||
* for whatever purpose the client desires.
|
||||
*/
|
||||
struct dns_name {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
unsigned char * ndata;
|
||||
unsigned int length;
|
||||
unsigned int labels;
|
||||
|
||||
@@ -44,7 +44,7 @@ ISC_LANG_BEGINDECLS
|
||||
|
||||
struct dns_ntatable {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_view_t *view;
|
||||
isc_rwlock_t rwlock;
|
||||
isc_taskmgr_t *taskmgr;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
***/
|
||||
|
||||
struct dns_peerlist {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
uint32_t refs;
|
||||
|
||||
isc_mem_t *mem;
|
||||
@@ -55,7 +55,7 @@ struct dns_peerlist {
|
||||
};
|
||||
|
||||
struct dns_peer {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
uint32_t refs;
|
||||
|
||||
isc_mem_t *mem;
|
||||
|
||||
@@ -69,7 +69,7 @@ enum {
|
||||
};
|
||||
struct dns_rbtnode {
|
||||
#if DNS_RBT_USEMAGIC
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
#endif
|
||||
/*@{*/
|
||||
/*!
|
||||
@@ -240,7 +240,7 @@ typedef void (*dns_rbtdeleter_t)(void *, void *);
|
||||
#define DNS_RBT_LEVELBLOCK 254
|
||||
|
||||
typedef struct dns_rbtnodechain {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
/*%
|
||||
* The terminal node of the chain. It is not in levels[].
|
||||
* This is ostensibly private ... but in a pinch it could be
|
||||
|
||||
@@ -105,7 +105,7 @@ typedef struct dns_rdatasetmethods {
|
||||
* rdataset implementations may change any of the fields.
|
||||
*/
|
||||
struct dns_rdataset {
|
||||
unsigned int magic; /* XXX ? */
|
||||
isc_magic_t magic; /* XXX ? */
|
||||
dns_rdatasetmethods_t * methods;
|
||||
ISC_LINK(dns_rdataset_t) link;
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ typedef struct dns_rdatasetitermethods {
|
||||
*/
|
||||
struct dns_rdatasetiter {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_rdatasetitermethods_t * methods;
|
||||
dns_db_t * db;
|
||||
dns_dbnode_t * node;
|
||||
|
||||
@@ -52,7 +52,7 @@ ISC_LANG_BEGINDECLS
|
||||
*/
|
||||
|
||||
typedef struct dns_rriterator {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_result_t result;
|
||||
dns_db_t *db;
|
||||
dns_dbiterator_t *dbit;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
typedef struct dns_tcpmsg {
|
||||
/* private (don't touch!) */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
uint16_t size;
|
||||
isc_buffer_t buffer;
|
||||
unsigned int maxsize;
|
||||
|
||||
@@ -72,7 +72,7 @@ struct dns_tsig_keyring {
|
||||
|
||||
struct dns_tsigkey {
|
||||
/* Unlocked */
|
||||
unsigned int magic; /*%< Magic number. */
|
||||
isc_magic_t magic; /*%< Magic number. */
|
||||
isc_mem_t *mctx;
|
||||
dst_key_t *key; /*%< Key */
|
||||
dns_name_t name; /*%< Key name */
|
||||
|
||||
@@ -117,7 +117,7 @@ typedef struct dns_validatorevent {
|
||||
*/
|
||||
struct dns_validator {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
dns_view_t * view;
|
||||
/* Locked by lock. */
|
||||
|
||||
@@ -80,7 +80,7 @@ ISC_LANG_BEGINDECLS
|
||||
|
||||
struct dns_view {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
dns_rdataclass_t rdclass;
|
||||
char * name;
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ dns_iptable_create(isc_mem_t *mctx, dns_iptable_t **target) {
|
||||
isc_mem_attach(mctx, &tab->mctx);
|
||||
isc_refcount_init(&tab->refcount, 1);
|
||||
tab->radix = NULL;
|
||||
tab->magic = DNS_IPTABLE_MAGIC;
|
||||
ISC_MAGIC_INIT(tab, DNS_IPTABLE_MAGIC);
|
||||
|
||||
result = isc_radix_create(mctx, &tab->radix, RADIX_MAXBITS);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -164,6 +164,6 @@ destroy_iptable(dns_iptable_t *dtab) {
|
||||
dtab->radix = NULL;
|
||||
}
|
||||
|
||||
dtab->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dtab);
|
||||
isc_mem_putanddetach(&dtab->mctx, dtab, sizeof(*dtab));
|
||||
}
|
||||
|
||||
+4
-4
@@ -294,7 +294,7 @@ typedef enum {
|
||||
} journal_state_t;
|
||||
|
||||
struct dns_journal {
|
||||
unsigned int magic; /*%< JOUR */
|
||||
isc_magic_t magic; /*%< JOUR */
|
||||
isc_mem_t *mctx; /*%< Memory context */
|
||||
journal_state_t state;
|
||||
char *filename; /*%< Journal file name */
|
||||
@@ -592,7 +592,7 @@ journal_open(isc_mem_t *mctx, const char *filename, bool writable,
|
||||
/*
|
||||
* Set magic early so that seek/read can succeed.
|
||||
*/
|
||||
j->magic = DNS_JOURNAL_MAGIC;
|
||||
ISC_MAGIC_INIT(j, DNS_JOURNAL_MAGIC);
|
||||
|
||||
CHECK(journal_seek(j, 0));
|
||||
CHECK(journal_read(j, &rawheader, sizeof(rawheader)));
|
||||
@@ -656,7 +656,7 @@ journal_open(isc_mem_t *mctx, const char *filename, bool writable,
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
failure:
|
||||
j->magic = 0;
|
||||
ISC_MAGIC_CLEAR(j);
|
||||
if (j->rawindex != NULL)
|
||||
isc_mem_put(j->mctx, j->rawindex, j->header.index_size *
|
||||
sizeof(journal_rawpos_t));
|
||||
@@ -1252,7 +1252,7 @@ dns_journal_destroy(dns_journal_t **journalp) {
|
||||
isc_mem_free(j->mctx, j->filename);
|
||||
if (j->fp != NULL)
|
||||
(void)isc_stdio_close(j->fp);
|
||||
j->magic = 0;
|
||||
ISC_MAGIC_CLEAR(j);
|
||||
isc_mem_putanddetach(&j->mctx, j, sizeof(*j));
|
||||
*journalp = NULL;
|
||||
}
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp)
|
||||
|
||||
// TODO: The rest of the KASP configuration
|
||||
|
||||
kasp->magic = DNS_KASP_MAGIC;
|
||||
ISC_MAGIC_INIT(kasp, DNS_KASP_MAGIC);
|
||||
*kaspp = kasp;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
+5
-5
@@ -38,7 +38,7 @@
|
||||
|
||||
struct dns_keytable {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t active_nodes;
|
||||
isc_refcount_t references;
|
||||
@@ -48,7 +48,7 @@ struct dns_keytable {
|
||||
};
|
||||
|
||||
struct dns_keynode {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_refcount_t refcount;
|
||||
dst_key_t *key;
|
||||
dns_rdatalist_t *dslist;
|
||||
@@ -95,7 +95,7 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
|
||||
|
||||
keytable->mctx = NULL;
|
||||
isc_mem_attach(mctx, &keytable->mctx);
|
||||
keytable->magic = KEYTABLE_MAGIC;
|
||||
ISC_MAGIC_INIT(keytable, KEYTABLE_MAGIC);
|
||||
*keytablep = keytable;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -135,7 +135,7 @@ dns_keytable_detach(dns_keytable_t **keytablep) {
|
||||
isc_refcount_destroy(&keytable->active_nodes);
|
||||
dns_rbt_destroy(&keytable->table);
|
||||
isc_rwlock_destroy(&keytable->rwlock);
|
||||
keytable->magic = 0;
|
||||
ISC_MAGIC_CLEAR(keytable);
|
||||
isc_mem_putanddetach(&keytable->mctx,
|
||||
keytable, sizeof(*keytable));
|
||||
}
|
||||
@@ -963,7 +963,7 @@ dns_keynode_create(isc_mem_t *mctx, dns_keynode_t **target) {
|
||||
|
||||
knode = isc_mem_get(mctx, sizeof(dns_keynode_t));
|
||||
|
||||
knode->magic = KEYNODE_MAGIC;
|
||||
ISC_MAGIC_INIT(knode, KEYNODE_MAGIC);
|
||||
knode->managed = false;
|
||||
knode->initial = false;
|
||||
knode->key = NULL;
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@
|
||||
|
||||
struct dns_lookup {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
isc_mutex_t lock;
|
||||
dns_rdatatype_t type;
|
||||
@@ -401,7 +401,7 @@ dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
|
||||
lookup->canceled = false;
|
||||
dns_rdataset_init(&lookup->rdataset);
|
||||
dns_rdataset_init(&lookup->sigrdataset);
|
||||
lookup->magic = LOOKUP_MAGIC;
|
||||
ISC_MAGIC_INIT(lookup, LOOKUP_MAGIC);
|
||||
|
||||
*lookupp = lookup;
|
||||
|
||||
@@ -443,7 +443,7 @@ dns_lookup_destroy(dns_lookup_t **lookupp) {
|
||||
dns_rdataset_disassociate(&lookup->sigrdataset);
|
||||
|
||||
isc_mutex_destroy(&lookup->lock);
|
||||
lookup->magic = 0;
|
||||
ISC_MAGIC_CLEAR(lookup);
|
||||
isc_mem_putanddetach(&lookup->mctx, lookup, sizeof(*lookup));
|
||||
|
||||
*lookupp = NULL;
|
||||
|
||||
+3
-3
@@ -97,7 +97,7 @@ typedef struct dns_incctx dns_incctx_t;
|
||||
*/
|
||||
|
||||
struct dns_loadctx {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_masterformat_t format;
|
||||
|
||||
@@ -435,7 +435,7 @@ loadctx_destroy(dns_loadctx_t *lctx) {
|
||||
|
||||
REQUIRE(DNS_LCTX_VALID(lctx));
|
||||
|
||||
lctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(lctx);
|
||||
if (lctx->inc != NULL)
|
||||
incctx_destroy(lctx->mctx, lctx->inc);
|
||||
|
||||
@@ -604,7 +604,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx,
|
||||
|
||||
isc_refcount_init(&lctx->references, 1); /* Implicit attach. */
|
||||
|
||||
lctx->magic = DNS_LCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(lctx, DNS_LCTX_MAGIC);
|
||||
*lctxp = lctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ static char spaces[N_SPACES+1] = " ";
|
||||
static char tabs[N_TABS+1] = "\t\t\t\t\t\t\t\t\t\t";
|
||||
|
||||
struct dns_dumpctx {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_refcount_t references;
|
||||
@@ -1276,7 +1276,7 @@ dumptostreaminc(dns_dumpctx_t *dctx);
|
||||
static void
|
||||
dumpctx_destroy(dns_dumpctx_t *dctx) {
|
||||
|
||||
dctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(dctx);
|
||||
isc_mutex_destroy(&dctx->lock);
|
||||
dns_dbiterator_destroy(&dctx->dbiter);
|
||||
if (dctx->version != NULL)
|
||||
@@ -1533,7 +1533,7 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
|
||||
isc_mem_attach(mctx, &dctx->mctx);
|
||||
|
||||
isc_refcount_init(&dctx->references, 1);
|
||||
dctx->magic = DNS_DCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(dctx, DNS_DCTX_MAGIC);
|
||||
*dctxp = dctx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
||||
+3
-3
@@ -717,7 +717,7 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
|
||||
* and other members that are freed in the cleanup phase here.
|
||||
*/
|
||||
|
||||
m->magic = DNS_MESSAGE_MAGIC;
|
||||
ISC_MAGIC_INIT(m, DNS_MESSAGE_MAGIC);
|
||||
m->from_to_wire = intent;
|
||||
msginit(m);
|
||||
|
||||
@@ -780,7 +780,7 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp)
|
||||
isc_mempool_destroy(&m->namepool);
|
||||
if (m->rdspool != NULL)
|
||||
isc_mempool_destroy(&m->rdspool);
|
||||
m->magic = 0;
|
||||
ISC_MAGIC_CLEAR(m);
|
||||
isc_mem_putanddetach(&mctx, m, sizeof(dns_message_t));
|
||||
|
||||
return (ISC_R_NOMEMORY);
|
||||
@@ -809,7 +809,7 @@ dns_message_destroy(dns_message_t **msgp) {
|
||||
msgreset(msg, true);
|
||||
isc_mempool_destroy(&msg->namepool);
|
||||
isc_mempool_destroy(&msg->rdspool);
|
||||
msg->magic = 0;
|
||||
ISC_MAGIC_CLEAR(msg);
|
||||
isc_mem_putanddetach(&msg->mctx, msg, sizeof(dns_message_t));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -197,7 +197,7 @@ dns_name_invalidate(dns_name_t *name) {
|
||||
|
||||
REQUIRE(VALID_NAME(name));
|
||||
|
||||
name->magic = 0;
|
||||
ISC_MAGIC_CLEAR(name);
|
||||
name->ndata = NULL;
|
||||
name->length = 0;
|
||||
name->labels = 0;
|
||||
|
||||
+5
-5
@@ -37,7 +37,7 @@
|
||||
#include <dns/time.h>
|
||||
|
||||
struct dns_nta {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_refcount_t refcount;
|
||||
dns_ntatable_t *ntatable;
|
||||
bool forced;
|
||||
@@ -70,7 +70,7 @@ nta_detach(isc_mem_t *mctx, dns_nta_t **ntap) {
|
||||
|
||||
if (isc_refcount_decrement(&nta->refcount) == 1) {
|
||||
isc_refcount_destroy(&nta->refcount);
|
||||
nta->magic = 0;
|
||||
ISC_MAGIC_CLEAR(nta);
|
||||
if (nta->timer != NULL) {
|
||||
(void)isc_timer_reset(nta->timer,
|
||||
isc_timertype_inactive,
|
||||
@@ -133,7 +133,7 @@ dns_ntatable_create(dns_view_t *view,
|
||||
ntatable->view = view;
|
||||
isc_refcount_init(&ntatable->references, 1);
|
||||
|
||||
ntatable->magic = NTATABLE_MAGIC;
|
||||
ISC_MAGIC_INIT(ntatable, NTATABLE_MAGIC);
|
||||
*ntatablep = ntatable;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -177,7 +177,7 @@ dns_ntatable_detach(dns_ntatable_t **ntatablep) {
|
||||
isc_task_detach(&ntatable->task);
|
||||
ntatable->timermgr = NULL;
|
||||
ntatable->taskmgr = NULL;
|
||||
ntatable->magic = 0;
|
||||
ISC_MAGIC_CLEAR(ntatable);
|
||||
isc_mem_put(ntatable->view->mctx, ntatable, sizeof(*ntatable));
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
|
||||
nta->name = dns_fixedname_initname(&nta->fn);
|
||||
dns_name_copynf(name, nta->name);
|
||||
|
||||
nta->magic = NTA_MAGIC;
|
||||
ISC_MAGIC_INIT(nta, NTA_MAGIC);
|
||||
|
||||
*target = nta;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
+4
-4
@@ -35,8 +35,8 @@ struct dns_order_ent {
|
||||
};
|
||||
|
||||
struct dns_order {
|
||||
unsigned int magic;
|
||||
isc_refcount_t references;
|
||||
isc_magic_t magic;
|
||||
isc_refcount_t references;
|
||||
ISC_LIST(dns_order_ent_t) ents;
|
||||
isc_mem_t *mctx;
|
||||
};
|
||||
@@ -59,7 +59,7 @@ dns_order_create(isc_mem_t *mctx, dns_order_t **orderp) {
|
||||
|
||||
order->mctx = NULL;
|
||||
isc_mem_attach(mctx, &order->mctx);
|
||||
order->magic = DNS_ORDER_MAGIC;
|
||||
ISC_MAGIC_INIT(order, DNS_ORDER_MAGIC);
|
||||
*orderp = order;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ dns_order_detach(dns_order_t **orderp) {
|
||||
|
||||
if (isc_refcount_decrement(&order->references) == 1) {
|
||||
isc_refcount_destroy(&order->references);
|
||||
order->magic = 0;
|
||||
ISC_MAGIC_CLEAR(order);
|
||||
dns_order_ent_t *ent;
|
||||
while ((ent = ISC_LIST_HEAD(order->ents)) != NULL) {
|
||||
ISC_LIST_UNLINK(order->ents, ent, link);
|
||||
|
||||
+4
-4
@@ -63,7 +63,7 @@ dns_peerlist_new(isc_mem_t *mem, dns_peerlist_t **list) {
|
||||
ISC_LIST_INIT(l->elements);
|
||||
l->mem = mem;
|
||||
l->refs = 1;
|
||||
l->magic = DNS_PEERLIST_MAGIC;
|
||||
ISC_MAGIC_INIT(l, DNS_PEERLIST_MAGIC);
|
||||
|
||||
*list = l;
|
||||
|
||||
@@ -122,7 +122,7 @@ peerlist_delete(dns_peerlist_t **list) {
|
||||
server = stmp;
|
||||
}
|
||||
|
||||
l->magic = 0;
|
||||
ISC_MAGIC_CLEAR(l);
|
||||
isc_mem_put(l->mem, l, sizeof(*l));
|
||||
|
||||
*list = NULL;
|
||||
@@ -222,7 +222,7 @@ dns_peer_newprefix(isc_mem_t *mem, const isc_netaddr_t *addr,
|
||||
|
||||
peer = isc_mem_get(mem, sizeof(*peer));
|
||||
|
||||
peer->magic = DNS_PEER_MAGIC;
|
||||
ISC_MAGIC_INIT(peer, DNS_PEER_MAGIC);
|
||||
peer->address = *addr;
|
||||
peer->prefixlen = prefixlen;
|
||||
peer->mem = mem;
|
||||
@@ -292,7 +292,7 @@ peer_delete(dns_peer_t **peer) {
|
||||
|
||||
mem = p->mem;
|
||||
p->mem = NULL;
|
||||
p->magic = 0;
|
||||
ISC_MAGIC_CLEAR(p);
|
||||
|
||||
if (p->key != NULL) {
|
||||
dns_name_free(p->key, mem);
|
||||
|
||||
+3
-3
@@ -38,7 +38,7 @@ typedef struct dns_element {
|
||||
} dns_element_t;
|
||||
|
||||
struct dns_portlist {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t refcount;
|
||||
isc_mutex_t lock;
|
||||
@@ -77,7 +77,7 @@ dns_portlist_create(isc_mem_t *mctx, dns_portlist_t **portlistp) {
|
||||
portlist->active = 0;
|
||||
portlist->mctx = NULL;
|
||||
isc_mem_attach(mctx, &portlist->mctx);
|
||||
portlist->magic = DNS_PORTLIST_MAGIC;
|
||||
ISC_MAGIC_INIT(portlist, DNS_PORTLIST_MAGIC);
|
||||
*portlistp = portlist;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ dns_portlist_detach(dns_portlist_t **portlistp) {
|
||||
*portlistp = NULL;
|
||||
|
||||
if (isc_refcount_decrement(&portlist->refcount) == 1) {
|
||||
portlist->magic = 0;
|
||||
ISC_MAGIC_CLEAR(portlist);
|
||||
isc_refcount_destroy(&portlist->refcount);
|
||||
if (portlist->list != NULL)
|
||||
isc_mem_put(portlist->mctx, portlist->list,
|
||||
|
||||
+8
-8
@@ -68,7 +68,7 @@
|
||||
#endif
|
||||
|
||||
struct dns_rbt {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
dns_rbtnode_t * root;
|
||||
void (*data_deleter)(void *, void *);
|
||||
@@ -973,7 +973,7 @@ dns_rbt_create(isc_mem_t *mctx, dns_rbtdeleter_t deleter,
|
||||
return (result);
|
||||
}
|
||||
|
||||
rbt->magic = RBT_MAGIC;
|
||||
ISC_MAGIC_INIT(rbt, RBT_MAGIC);
|
||||
|
||||
*rbtp = rbt;
|
||||
|
||||
@@ -1008,7 +1008,7 @@ dns_rbt_destroy2(dns_rbt_t **rbtp, unsigned int quantum) {
|
||||
isc_mem_put(rbt->mctx, rbt->hashtable,
|
||||
rbt->hashsize * sizeof(dns_rbtnode_t *));
|
||||
|
||||
rbt->magic = 0;
|
||||
ISC_MAGIC_CLEAR(rbt);
|
||||
|
||||
isc_mem_putanddetach(&rbt->mctx, rbt, sizeof(*rbt));
|
||||
*rbtp = NULL;
|
||||
@@ -2099,7 +2099,7 @@ dns_rbt_deletenode(dns_rbt_t *rbt, dns_rbtnode_t *node, bool recurse)
|
||||
|
||||
unhash_node(rbt, node);
|
||||
#if DNS_RBT_USEMAGIC
|
||||
node->magic = 0;
|
||||
ISC_MAGIC_CLEAR(node);
|
||||
#endif
|
||||
isc_refcount_destroy(&node->references);
|
||||
|
||||
@@ -2239,7 +2239,7 @@ create_node(isc_mem_t *mctx, const dns_name_t *name, dns_rbtnode_t **nodep) {
|
||||
memmove(OFFSETS(node), name->offsets, labels);
|
||||
|
||||
#if DNS_RBT_USEMAGIC
|
||||
node->magic = DNS_RBTNODE_MAGIC;
|
||||
ISC_MAGIC_INIT(node, DNS_RBTNODE_MAGIC);
|
||||
#endif
|
||||
*nodep = node;
|
||||
|
||||
@@ -2818,7 +2818,7 @@ deletetreeflat(dns_rbt_t *rbt, unsigned int quantum, bool unhash,
|
||||
* are destroying the complete RBT tree.
|
||||
*/
|
||||
#if DNS_RBT_USEMAGIC
|
||||
node->magic = 0;
|
||||
ISC_MAGIC_CLEAR(node);
|
||||
#endif
|
||||
freenode(rbt, &node);
|
||||
if (quantum != 0 && --quantum == 0)
|
||||
@@ -3158,7 +3158,7 @@ dns_rbtnodechain_init(dns_rbtnodechain_t *chain) {
|
||||
chain->level_matches = 0;
|
||||
memset(chain->levels, 0, sizeof(chain->levels));
|
||||
|
||||
chain->magic = CHAIN_MAGIC;
|
||||
ISC_MAGIC_INIT(chain, CHAIN_MAGIC);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -3634,7 +3634,7 @@ dns_rbtnodechain_invalidate(dns_rbtnodechain_t *chain) {
|
||||
|
||||
dns_rbtnodechain_reset(chain);
|
||||
|
||||
chain->magic = 0;
|
||||
ISC_MAGIC_CLEAR(chain);
|
||||
}
|
||||
|
||||
/* XXXMUKS:
|
||||
|
||||
+9
-8
@@ -107,8 +107,9 @@ struct rbtdb_file_header {
|
||||
* Note that "impmagic" is not the first four bytes of the struct, so
|
||||
* ISC_MAGIC_VALID cannot be used.
|
||||
*/
|
||||
#define VALID_RBTDB(rbtdb) ((rbtdb) != NULL && \
|
||||
(rbtdb)->common.impmagic == RBTDB_MAGIC)
|
||||
#define VALID_RBTDB(rbtdb) \
|
||||
((rbtdb) != NULL && \
|
||||
atomic_load_acquire(&(rbtdb)->common.impmagic) == RBTDB_MAGIC)
|
||||
|
||||
typedef uint32_t rbtdb_serial_t;
|
||||
typedef uint32_t rbtdb_rdatatype_t;
|
||||
@@ -1121,8 +1122,8 @@ free_rbtdb(dns_rbtdb_t *rbtdb, bool log, isc_event_t *event) {
|
||||
isc_task_detach(&rbtdb->task);
|
||||
|
||||
RBTDB_DESTROYLOCK(&rbtdb->lock);
|
||||
rbtdb->common.magic = 0;
|
||||
rbtdb->common.impmagic = 0;
|
||||
ISC_MAGIC_CLEAR(&rbtdb->common);
|
||||
ISC_IMPMAGIC_CLEAR(&rbtdb->common);
|
||||
isc_mem_detach(&rbtdb->hmctx);
|
||||
|
||||
if (rbtdb->mmap_location != NULL)
|
||||
@@ -5388,7 +5389,7 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
|
||||
dns_db_attach(db, &rbtdbiter->common.db);
|
||||
rbtdbiter->common.relative_names =
|
||||
((options & DNS_DB_RELATIVENAMES) != 0);
|
||||
rbtdbiter->common.magic = DNS_DBITERATOR_MAGIC;
|
||||
ISC_MAGIC_INIT(&rbtdbiter->common, DNS_DBITERATOR_MAGIC);
|
||||
rbtdbiter->common.cleaning = false;
|
||||
rbtdbiter->paused = true;
|
||||
rbtdbiter->tree_locked = isc_rwlocktype_none;
|
||||
@@ -5623,7 +5624,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
rbtversion = NULL;
|
||||
}
|
||||
|
||||
iterator->common.magic = DNS_RDATASETITER_MAGIC;
|
||||
ISC_MAGIC_INIT(&iterator->common, DNS_RDATASETITER_MAGIC);
|
||||
iterator->common.methods = &rdatasetiter_methods;
|
||||
iterator->common.db = db;
|
||||
iterator->common.node = node;
|
||||
@@ -8323,8 +8324,8 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
*/
|
||||
PREPEND(rbtdb->open_versions, rbtdb->current_version, link);
|
||||
|
||||
rbtdb->common.magic = DNS_DB_MAGIC;
|
||||
rbtdb->common.impmagic = RBTDB_MAGIC;
|
||||
ISC_MAGIC_INIT(&rbtdb->common, DNS_DB_MAGIC);
|
||||
ISC_IMPMAGIC_INIT(&rbtdb->common, RBTDB_MAGIC);
|
||||
|
||||
*dbp = (dns_db_t *)rbtdb;
|
||||
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ dns_rdataset_init(dns_rdataset_t *rdataset) {
|
||||
|
||||
REQUIRE(rdataset != NULL);
|
||||
|
||||
rdataset->magic = DNS_RDATASET_MAGIC;
|
||||
ISC_MAGIC_INIT(rdataset, DNS_RDATASET_MAGIC);
|
||||
rdataset->methods = NULL;
|
||||
ISC_LINK_INIT(rdataset, link);
|
||||
rdataset->rdclass = 0;
|
||||
@@ -89,7 +89,7 @@ dns_rdataset_invalidate(dns_rdataset_t *rdataset) {
|
||||
REQUIRE(DNS_RDATASET_VALID(rdataset));
|
||||
REQUIRE(rdataset->methods == NULL);
|
||||
|
||||
rdataset->magic = 0;
|
||||
ISC_MAGIC_CLEAR(rdataset);
|
||||
ISC_LINK_INIT(rdataset, link);
|
||||
rdataset->rdclass = 0;
|
||||
rdataset->type = 0;
|
||||
|
||||
+7
-7
@@ -43,7 +43,7 @@ typedef ISC_LIST(dns_request_t) dns_requestlist_t;
|
||||
#define DNS_REQUEST_NLOCKS 7
|
||||
|
||||
struct dns_requestmgr {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
@@ -64,7 +64,7 @@ struct dns_requestmgr {
|
||||
};
|
||||
|
||||
struct dns_request {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
unsigned int hash;
|
||||
isc_mem_t *mctx;
|
||||
int32_t flags;
|
||||
@@ -184,7 +184,7 @@ dns_requestmgr_create(isc_mem_t *mctx,
|
||||
ISC_LIST_INIT(requestmgr->requests);
|
||||
requestmgr->exiting = false;
|
||||
requestmgr->hash = 0;
|
||||
requestmgr->magic = REQUESTMGR_MAGIC;
|
||||
ISC_MAGIC_INIT(requestmgr, REQUESTMGR_MAGIC);
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "dns_requestmgr_create: %p", requestmgr);
|
||||
|
||||
@@ -387,7 +387,7 @@ mgr_destroy(dns_requestmgr_t *requestmgr) {
|
||||
dns_dispatch_detach(&requestmgr->dispatchv4);
|
||||
if (requestmgr->dispatchv6 != NULL)
|
||||
dns_dispatch_detach(&requestmgr->dispatchv6);
|
||||
requestmgr->magic = 0;
|
||||
ISC_MAGIC_CLEAR(requestmgr);
|
||||
isc_mem_putanddetach(&requestmgr->mctx, requestmgr, sizeof(*requestmgr));
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ new_request(isc_mem_t *mctx, dns_request_t **requestp)
|
||||
/*
|
||||
* Zero structure.
|
||||
*/
|
||||
request->magic = 0;
|
||||
ISC_MAGIC_CLEAR(request);
|
||||
request->mctx = NULL;
|
||||
request->flags = 0;
|
||||
ISC_LINK_INIT(request, link);
|
||||
@@ -472,7 +472,7 @@ new_request(isc_mem_t *mctx, dns_request_t **requestp)
|
||||
|
||||
isc_mem_attach(mctx, &request->mctx);
|
||||
|
||||
request->magic = REQUEST_MAGIC;
|
||||
ISC_MAGIC_INIT(request, REQUEST_MAGIC);
|
||||
*requestp = request;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -1420,7 +1420,7 @@ req_destroy(dns_request_t *request) {
|
||||
|
||||
req_log(ISC_LOG_DEBUG(3), "req_destroy: request %p", request);
|
||||
|
||||
request->magic = 0;
|
||||
ISC_MAGIC_CLEAR(request);
|
||||
if (request->query != NULL)
|
||||
isc_buffer_free(&request->query);
|
||||
if (request->answer != NULL)
|
||||
|
||||
+12
-12
@@ -195,7 +195,7 @@ typedef struct fetchctx fetchctx_t;
|
||||
|
||||
typedef struct query {
|
||||
/* Locked by task event serialization. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
fetchctx_t * fctx;
|
||||
isc_mem_t * mctx;
|
||||
dns_dispatchmgr_t * dispatchmgr;
|
||||
@@ -252,7 +252,7 @@ typedef enum {
|
||||
|
||||
struct fetchctx {
|
||||
/*% Not locked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_resolver_t * res;
|
||||
dns_name_t name;
|
||||
dns_rdatatype_t type;
|
||||
@@ -420,7 +420,7 @@ typedef struct {
|
||||
} dns_valarg_t;
|
||||
|
||||
struct dns_fetch {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
fetchctx_t * private;
|
||||
};
|
||||
@@ -467,7 +467,7 @@ typedef struct alternate {
|
||||
|
||||
struct dns_resolver {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_mutex_t primelock;
|
||||
@@ -1134,7 +1134,7 @@ resquery_destroy(resquery_t **queryp) {
|
||||
empty = fctx_decreference(query->fctx);
|
||||
UNLOCK(&res->buckets[bucket].lock);
|
||||
|
||||
query->magic = 0;
|
||||
ISC_MAGIC_CLEAR(query);
|
||||
isc_mem_put(query->mctx, query, sizeof(*query));
|
||||
*queryp = NULL;
|
||||
|
||||
@@ -2115,7 +2115,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
||||
query->tsig = NULL;
|
||||
query->tsigkey = NULL;
|
||||
ISC_LINK_INIT(query, link);
|
||||
query->magic = QUERY_MAGIC;
|
||||
ISC_MAGIC_INIT(query, QUERY_MAGIC);
|
||||
|
||||
if ((query->options & DNS_FETCHOPT_TCP) != 0) {
|
||||
/*
|
||||
@@ -2167,7 +2167,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
||||
|
||||
cleanup_query:
|
||||
if (query->connects == 0) {
|
||||
query->magic = 0;
|
||||
ISC_MAGIC_CLEAR(query);
|
||||
isc_mem_put(fctx->mctx, query, sizeof(*query));
|
||||
}
|
||||
|
||||
@@ -4701,7 +4701,7 @@ fctx_join(fetchctx_t *fctx, isc_task_t *task, const isc_sockaddr_t *client,
|
||||
|
||||
fctx->client = client;
|
||||
|
||||
fetch->magic = DNS_FETCH_MAGIC;
|
||||
ISC_MAGIC_INIT(fetch, DNS_FETCH_MAGIC);
|
||||
fetch->private = fctx;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -5016,7 +5016,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
|
||||
|
||||
ISC_LIST_INIT(fctx->events);
|
||||
ISC_LINK_INIT(fctx, link);
|
||||
fctx->magic = FCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(fctx, FCTX_MAGIC);
|
||||
|
||||
/*
|
||||
* If qname minimization is enabled we need to trim
|
||||
@@ -5043,7 +5043,7 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type,
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_mctx:
|
||||
fctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(fctx);
|
||||
isc_mem_detach(&fctx->mctx);
|
||||
dns_adb_detach(&fctx->adb);
|
||||
dns_db_detach(&fctx->cache);
|
||||
@@ -9882,7 +9882,7 @@ destroy(dns_resolver_t *res) {
|
||||
isc_rwlock_destroy(&res->mbslock);
|
||||
#endif
|
||||
isc_timer_detach(&res->spillattimer);
|
||||
res->magic = 0;
|
||||
ISC_MAGIC_CLEAR(res);
|
||||
isc_mem_put(res->mctx, res, sizeof(*res));
|
||||
}
|
||||
|
||||
@@ -10120,7 +10120,7 @@ dns_resolver_create(dns_view_t *view,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
res->magic = RES_MAGIC;
|
||||
ISC_MAGIC_INIT(res, RES_MAGIC);
|
||||
|
||||
*resp = res;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ dns_rriterator_init(dns_rriterator_t *it, dns_db_t *db, dns_dbversion_t *ver,
|
||||
isc_stdtime_t now)
|
||||
{
|
||||
isc_result_t result;
|
||||
it->magic = RRITERATOR_MAGIC;
|
||||
ISC_MAGIC_INIT(it, RRITERATOR_MAGIC);
|
||||
it->db = db;
|
||||
it->dbit = NULL;
|
||||
it->ver = ver;
|
||||
|
||||
+9
-9
@@ -64,7 +64,7 @@ struct dns_sdb {
|
||||
|
||||
struct dns_sdblookup {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_sdb_t *sdb;
|
||||
ISC_LIST(dns_rdatalist_t) lists;
|
||||
ISC_LIST(isc_buffer_t) buffers;
|
||||
@@ -531,8 +531,8 @@ destroy(dns_sdb_t *sdb) {
|
||||
|
||||
isc_mem_free(sdb->common.mctx, sdb->zone);
|
||||
|
||||
sdb->common.magic = 0;
|
||||
sdb->common.impmagic = 0;
|
||||
ISC_MAGIC_CLEAR(&sdb->common);
|
||||
ISC_IMPMAGIC_CLEAR(&sdb->common);
|
||||
|
||||
dns_name_free(&sdb->common.origin, sdb->common.mctx);
|
||||
|
||||
@@ -633,7 +633,7 @@ createnode(dns_sdb_t *sdb, dns_sdbnode_t **nodep) {
|
||||
|
||||
isc_refcount_init(&node->references, 1);
|
||||
|
||||
node->magic = SDBLOOKUP_MAGIC;
|
||||
ISC_MAGIC_INIT(node, SDBLOOKUP_MAGIC);
|
||||
|
||||
*nodep = node;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -672,7 +672,7 @@ destroynode(dns_sdbnode_t *node) {
|
||||
isc_mem_put(mctx, node->name, sizeof(dns_name_t));
|
||||
}
|
||||
|
||||
node->magic = 0;
|
||||
ISC_MAGIC_CLEAR(node);
|
||||
isc_mem_put(mctx, node, sizeof(dns_sdbnode_t));
|
||||
detach((dns_db_t **) (void *)&sdb);
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
|
||||
sdbiter->common.db = NULL;
|
||||
dns_db_attach(db, &sdbiter->common.db);
|
||||
sdbiter->common.relative_names = ((options & DNS_DB_RELATIVENAMES) != 0);
|
||||
sdbiter->common.magic = DNS_DBITERATOR_MAGIC;
|
||||
ISC_MAGIC_INIT(&sdbiter->common, DNS_DBITERATOR_MAGIC);
|
||||
ISC_LIST_INIT(sdbiter->nodelist);
|
||||
sdbiter->current = NULL;
|
||||
sdbiter->origin = NULL;
|
||||
@@ -1172,7 +1172,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
|
||||
iterator = isc_mem_get(db->mctx, sizeof(sdb_rdatasetiter_t));
|
||||
|
||||
iterator->common.magic = DNS_RDATASETITER_MAGIC;
|
||||
ISC_MAGIC_INIT(&iterator->common, DNS_RDATASETITER_MAGIC);
|
||||
iterator->common.methods = &rdatasetiter_methods;
|
||||
iterator->common.db = db;
|
||||
iterator->common.node = NULL;
|
||||
@@ -1367,8 +1367,8 @@ dns_sdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
|
||||
isc_refcount_init(&sdb->references, 1);
|
||||
|
||||
sdb->common.magic = DNS_DB_MAGIC;
|
||||
sdb->common.impmagic = SDB_MAGIC;
|
||||
ISC_MAGIC_INIT(&sdb->common, DNS_DB_MAGIC);
|
||||
ISC_IMPMAGIC_INIT(&sdb->common, SDB_MAGIC);
|
||||
|
||||
*dbp = (dns_db_t *)sdb;
|
||||
|
||||
|
||||
+9
-9
@@ -109,7 +109,7 @@ struct dns_sdlz_db {
|
||||
|
||||
struct dns_sdlzlookup {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_sdlz_db_t *sdlz;
|
||||
ISC_LIST(dns_rdatalist_t) lists;
|
||||
ISC_LIST(isc_buffer_t) buffers;
|
||||
@@ -327,8 +327,8 @@ attach(dns_db_t *source, dns_db_t **targetp) {
|
||||
|
||||
static void
|
||||
destroy(dns_sdlz_db_t *sdlz) {
|
||||
sdlz->common.magic = 0;
|
||||
sdlz->common.impmagic = 0;
|
||||
ISC_MAGIC_CLEAR(&sdlz->common);
|
||||
ISC_IMPMAGIC_CLEAR(&sdlz->common);
|
||||
|
||||
dns_name_free(&sdlz->common.origin, sdlz->common.mctx);
|
||||
|
||||
@@ -465,7 +465,7 @@ createnode(dns_sdlz_db_t *sdlz, dns_sdlznode_t **nodep) {
|
||||
dns_rdatacallbacks_init(&node->callbacks);
|
||||
|
||||
isc_refcount_init(&node->references, 1);
|
||||
node->magic = SDLZLOOKUP_MAGIC;
|
||||
ISC_MAGIC_INIT(node, SDLZLOOKUP_MAGIC);
|
||||
|
||||
*nodep = node;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -506,7 +506,7 @@ destroynode(dns_sdlznode_t *node) {
|
||||
}
|
||||
isc_refcount_destroy(&node->references);
|
||||
|
||||
node->magic = 0;
|
||||
ISC_MAGIC_CLEAR(node);
|
||||
isc_mem_put(mctx, node, sizeof(dns_sdlznode_t));
|
||||
db = &sdlz->common;
|
||||
detach(&db);
|
||||
@@ -785,7 +785,7 @@ createiterator(dns_db_t *db, unsigned int options, dns_dbiterator_t **iteratorp)
|
||||
dns_db_attach(db, &sdlziter->common.db);
|
||||
sdlziter->common.relative_names =
|
||||
((options & DNS_DB_RELATIVENAMES) != 0);
|
||||
sdlziter->common.magic = DNS_DBITERATOR_MAGIC;
|
||||
ISC_MAGIC_INIT(&sdlziter->common, DNS_DBITERATOR_MAGIC);
|
||||
ISC_LIST_INIT(sdlziter->nodelist);
|
||||
sdlziter->current = NULL;
|
||||
sdlziter->origin = NULL;
|
||||
@@ -1036,7 +1036,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
|
||||
|
||||
iterator = isc_mem_get(db->mctx, sizeof(sdlz_rdatasetiter_t));
|
||||
|
||||
iterator->common.magic = DNS_RDATASETITER_MAGIC;
|
||||
ISC_MAGIC_INIT(&iterator->common, DNS_RDATASETITER_MAGIC);
|
||||
iterator->common.methods = &rdatasetiter_methods;
|
||||
iterator->common.db = db;
|
||||
iterator->common.node = NULL;
|
||||
@@ -1513,8 +1513,8 @@ dns_sdlzcreateDBP(isc_mem_t *mctx, void *driverarg, void *dbdata,
|
||||
isc_mem_attach(mctx, &sdlzdb->common.mctx);
|
||||
|
||||
/* mark structure as valid */
|
||||
sdlzdb->common.magic = DNS_DB_MAGIC;
|
||||
sdlzdb->common.impmagic = SDLZDB_MAGIC;
|
||||
ISC_MAGIC_INIT(&sdlzdb->common, DNS_DB_MAGIC);
|
||||
ISC_IMPMAGIC_INIT(&sdlzdb->common, SDLZDB_MAGIC);
|
||||
*dbp = (dns_db_t *) sdlzdb;
|
||||
|
||||
return (result);
|
||||
|
||||
+7
-7
@@ -37,7 +37,7 @@
|
||||
#define VALID_SSURULE(table) ISC_MAGIC_VALID(table, SSURULEMAGIC)
|
||||
|
||||
struct dns_ssurule {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
bool grant; /*%< is this a grant or a deny? */
|
||||
dns_ssumatchtype_t matchtype; /*%< which type of pattern match? */
|
||||
dns_name_t *identity; /*%< the identity to match */
|
||||
@@ -50,7 +50,7 @@ struct dns_ssurule {
|
||||
};
|
||||
|
||||
struct dns_ssutable {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t references;
|
||||
dns_dlzdb_t *dlzdatabase;
|
||||
@@ -69,7 +69,7 @@ dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **tablep) {
|
||||
table->mctx = NULL;
|
||||
isc_mem_attach(mctx, &table->mctx);
|
||||
ISC_LIST_INIT(table->rules);
|
||||
table->magic = SSUTABLEMAGIC;
|
||||
ISC_MAGIC_INIT(table, SSUTABLEMAGIC);
|
||||
*tablep = table;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -95,11 +95,11 @@ destroy(dns_ssutable_t *table) {
|
||||
isc_mem_put(mctx, rule->types,
|
||||
rule->ntypes * sizeof(dns_rdatatype_t));
|
||||
ISC_LIST_UNLINK(table->rules, rule, link);
|
||||
rule->magic = 0;
|
||||
ISC_MAGIC_CLEAR(rule);
|
||||
isc_mem_put(mctx, rule, sizeof(dns_ssurule_t));
|
||||
}
|
||||
isc_refcount_destroy(&table->references);
|
||||
table->magic = 0;
|
||||
ISC_MAGIC_CLEAR(table);
|
||||
isc_mem_putanddetach(&table->mctx, table, sizeof(dns_ssutable_t));
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ dns_ssutable_addrule(dns_ssutable_t *table, bool grant,
|
||||
} else
|
||||
rule->types = NULL;
|
||||
|
||||
rule->magic = SSURULEMAGIC;
|
||||
ISC_MAGIC_INIT(rule, SSURULEMAGIC);
|
||||
ISC_LIST_INITANDAPPEND(table->rules, rule, link);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -613,7 +613,7 @@ dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep,
|
||||
rule->matchtype = dns_ssumatchtype_dlz;
|
||||
rule->ntypes = 0;
|
||||
rule->types = NULL;
|
||||
rule->magic = SSURULEMAGIC;
|
||||
ISC_MAGIC_INIT(rule, SSURULEMAGIC);
|
||||
|
||||
ISC_LIST_INITANDAPPEND(table->rules, rule, link);
|
||||
*tablep = table;
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ enum {
|
||||
static int dnssec_keyid_max = 65535;
|
||||
|
||||
struct dns_stats {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_statstype_t type;
|
||||
isc_mem_t *mctx;
|
||||
isc_stats_t *counters;
|
||||
@@ -149,7 +149,7 @@ create_stats(isc_mem_t *mctx, dns_statstype_t type, int ncounters,
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto clean_mutex;
|
||||
|
||||
stats->magic = DNS_STATS_MAGIC;
|
||||
ISC_MAGIC_INIT(stats, DNS_STATS_MAGIC);
|
||||
stats->type = type;
|
||||
stats->mctx = NULL;
|
||||
isc_mem_attach(mctx, &stats->mctx);
|
||||
|
||||
+2
-2
@@ -129,7 +129,7 @@ dns_tcpmsg_init(isc_mem_t *mctx, isc_socket_t *sock, dns_tcpmsg_t *tcpmsg) {
|
||||
REQUIRE(sock != NULL);
|
||||
REQUIRE(tcpmsg != NULL);
|
||||
|
||||
tcpmsg->magic = TCPMSG_MAGIC;
|
||||
ISC_MAGIC_INIT(tcpmsg, TCPMSG_MAGIC);
|
||||
tcpmsg->size = 0;
|
||||
tcpmsg->buffer.base = NULL;
|
||||
tcpmsg->buffer.length = 0;
|
||||
@@ -226,7 +226,7 @@ void
|
||||
dns_tcpmsg_invalidate(dns_tcpmsg_t *tcpmsg) {
|
||||
REQUIRE(VALID_TCPMSG(tcpmsg));
|
||||
|
||||
tcpmsg->magic = 0;
|
||||
ISC_MAGIC_CLEAR(tcpmsg);
|
||||
|
||||
if (tcpmsg->buffer.base != NULL) {
|
||||
isc_mem_put(tcpmsg->mctx, tcpmsg->buffer.base,
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@
|
||||
* multiple threads, and so the structure does not contain a lock.
|
||||
*/
|
||||
struct dns_tsec {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_tsectype_t type;
|
||||
isc_mem_t *mctx;
|
||||
union {
|
||||
@@ -97,7 +97,7 @@ dns_tsec_create(isc_mem_t *mctx, dns_tsectype_t type, dst_key_t *key,
|
||||
ISC_UNREACHABLE();
|
||||
}
|
||||
|
||||
tsec->magic = DNS_TSEC_MAGIC;
|
||||
ISC_MAGIC_INIT(tsec, DNS_TSEC_MAGIC);
|
||||
|
||||
*tsecp = tsec;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -123,7 +123,7 @@ dns_tsec_destroy(dns_tsec_t **tsecp) {
|
||||
ISC_UNREACHABLE();
|
||||
}
|
||||
|
||||
tsec->magic = 0;
|
||||
ISC_MAGIC_CLEAR(tsec);
|
||||
isc_mem_put(tsec->mctx, tsec, sizeof(*tsec));
|
||||
|
||||
*tsecp = NULL;
|
||||
|
||||
+3
-3
@@ -330,7 +330,7 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
|
||||
isc_mem_attach(mctx, &tkey->mctx);
|
||||
ISC_LINK_INIT(tkey, link);
|
||||
|
||||
tkey->magic = TSIG_MAGIC;
|
||||
ISC_MAGIC_INIT(tkey, TSIG_MAGIC);
|
||||
|
||||
if (ring != NULL) {
|
||||
ret = keyring_add(ring, name, tkey);
|
||||
@@ -357,7 +357,7 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_refs:
|
||||
tkey->magic = 0;
|
||||
ISC_MAGIC_CLEAR(tkey);
|
||||
while (refs-- > 0) {
|
||||
INSIST(isc_refcount_decrement(&tkey->refs) > 0);
|
||||
}
|
||||
@@ -712,7 +712,7 @@ static void
|
||||
tsigkey_free(dns_tsigkey_t *key) {
|
||||
REQUIRE(VALID_TSIG_KEY(key));
|
||||
|
||||
key->magic = 0;
|
||||
ISC_MAGIC_CLEAR(key);
|
||||
dns_name_free(&key->name, key->mctx);
|
||||
if (dns__tsig_algallocated(key->algorithm)) {
|
||||
dns_name_t *name;
|
||||
|
||||
+3
-3
@@ -1437,7 +1437,7 @@ dns_update_signatures(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
|
||||
}
|
||||
|
||||
struct dns_update_state {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_diff_t diffnames;
|
||||
dns_diff_t affected;
|
||||
dns_diff_t sig_diff;
|
||||
@@ -1566,7 +1566,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
|
||||
*/
|
||||
CHECK(dns_diff_sort(diff, temp_order));
|
||||
state->state = sign_updates;
|
||||
state->magic = STATE_MAGIC;
|
||||
ISC_MAGIC_INIT(state, STATE_MAGIC);
|
||||
if (statep != NULL)
|
||||
*statep = state;
|
||||
} else {
|
||||
@@ -2148,7 +2148,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db,
|
||||
|
||||
if (state != &mystate && state != NULL) {
|
||||
*statep = NULL;
|
||||
state->magic = 0;
|
||||
ISC_MAGIC_CLEAR(state);
|
||||
isc_mem_put(diff->mctx, state, sizeof(*state));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -3291,7 +3291,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
||||
dns_fixedname_init(&val->closest);
|
||||
isc_stdtime_get(&val->start);
|
||||
ISC_LINK_INIT(val, link);
|
||||
val->magic = VALIDATOR_MAGIC;
|
||||
ISC_MAGIC_INIT(val, VALIDATOR_MAGIC);
|
||||
|
||||
if ((options & DNS_VALIDATOR_DEFER) == 0) {
|
||||
isc_task_send(task, ISC_EVENT_PTR(&event));
|
||||
@@ -3386,7 +3386,7 @@ destroy(dns_validator_t *val) {
|
||||
}
|
||||
isc_mutex_destroy(&val->lock);
|
||||
dns_view_weakdetach(&val->view);
|
||||
val->magic = 0;
|
||||
ISC_MAGIC_CLEAR(val);
|
||||
isc_mem_put(mctx, val, sizeof(*val));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
DNS_EVENT_VIEWREQSHUTDOWN, req_shutdown,
|
||||
view, NULL, NULL, NULL);
|
||||
view->viewlist = NULL;
|
||||
view->magic = DNS_VIEW_MAGIC;
|
||||
ISC_MAGIC_INIT(view, DNS_VIEW_MAGIC);
|
||||
|
||||
*viewp = view;
|
||||
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ typedef enum {
|
||||
*/
|
||||
|
||||
struct dns_xfrin_ctx {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_zone_t *zone;
|
||||
|
||||
@@ -884,7 +884,7 @@ xfrin_create(isc_mem_t *mctx,
|
||||
isc_buffer_init(&xfr->qbuffer, &xfr->qbuffer_data[2],
|
||||
sizeof(xfr->qbuffer_data) - 2);
|
||||
|
||||
xfr->magic = XFRIN_MAGIC;
|
||||
ISC_MAGIC_INIT(xfr, XFRIN_MAGIC);
|
||||
*xfrp = xfr;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
|
||||
+27
-26
@@ -18,6 +18,7 @@
|
||||
#include <isc/atomic.h>
|
||||
#include <isc/file.h>
|
||||
#include <isc/hex.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/pool.h>
|
||||
#include <isc/print.h>
|
||||
@@ -190,7 +191,7 @@ extern bool dns_fuzzing_resolver;
|
||||
|
||||
struct dns_zone {
|
||||
/* Unlocked */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
#ifdef DNS_ZONE_CHECKLOCK
|
||||
bool locked;
|
||||
@@ -527,7 +528,7 @@ struct dns_unreachable {
|
||||
};
|
||||
|
||||
struct dns_zonemgr {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
int refs; /* Locked by rwlock */
|
||||
isc_taskmgr_t * taskmgr;
|
||||
@@ -573,7 +574,7 @@ struct dns_zonemgr {
|
||||
* Hold notify state.
|
||||
*/
|
||||
struct dns_notify {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
unsigned int flags;
|
||||
isc_mem_t *mctx;
|
||||
dns_zone_t *zone;
|
||||
@@ -597,7 +598,7 @@ struct dns_notify {
|
||||
*/
|
||||
|
||||
struct dns_stub {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_zone_t *zone;
|
||||
dns_db_t *db;
|
||||
@@ -608,7 +609,7 @@ struct dns_stub {
|
||||
* Hold load state.
|
||||
*/
|
||||
struct dns_load {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_zone_t *zone;
|
||||
dns_db_t *db;
|
||||
@@ -620,7 +621,7 @@ struct dns_load {
|
||||
* Hold forward state.
|
||||
*/
|
||||
struct dns_forward {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_zone_t *zone;
|
||||
isc_buffer_t *msgbuf;
|
||||
@@ -637,7 +638,7 @@ struct dns_forward {
|
||||
* Hold IO request state.
|
||||
*/
|
||||
struct dns_io {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_zonemgr_t *zmgr;
|
||||
bool high;
|
||||
isc_task_t *task;
|
||||
@@ -650,7 +651,7 @@ struct dns_io {
|
||||
* DNSKEY as result of an update.
|
||||
*/
|
||||
struct dns_signing {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_db_t *db;
|
||||
dns_dbiterator_t *dbiterator;
|
||||
dns_secalg_t algorithm;
|
||||
@@ -661,7 +662,7 @@ struct dns_signing {
|
||||
};
|
||||
|
||||
struct dns_nsec3chain {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
dns_db_t *db;
|
||||
dns_dbiterator_t *dbiterator;
|
||||
dns_rdata_nsec3param_t nsec3param;
|
||||
@@ -1067,7 +1068,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||
zone->updatemethod = dns_updatemethod_increment;
|
||||
zone->maxrecords = 0U;
|
||||
|
||||
zone->magic = ZONE_MAGIC;
|
||||
ISC_MAGIC_INIT(zone, ZONE_MAGIC);
|
||||
|
||||
zone->gluecachestats = NULL;
|
||||
result = isc_stats_create(mctx, &zone->gluecachestats,
|
||||
@@ -1270,7 +1271,7 @@ zone_free(dns_zone_t *zone) {
|
||||
/* last stuff */
|
||||
ZONEDB_DESTROYLOCK(&zone->dblock);
|
||||
isc_mutex_destroy(&zone->lock);
|
||||
zone->magic = 0;
|
||||
ISC_MAGIC_CLEAR(zone);
|
||||
isc_mem_putanddetach(&zone->mctx, zone, sizeof(*zone));
|
||||
}
|
||||
|
||||
@@ -2506,7 +2507,7 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) {
|
||||
load->zone = NULL;
|
||||
load->db = NULL;
|
||||
load->loadtime = loadtime;
|
||||
load->magic = LOAD_MAGIC;
|
||||
ISC_MAGIC_INIT(load, LOAD_MAGIC);
|
||||
|
||||
isc_mem_attach(zone->mctx, &load->mctx);
|
||||
zone_iattach(zone, &load->zone);
|
||||
@@ -2560,7 +2561,7 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) {
|
||||
return (result);
|
||||
|
||||
cleanup:
|
||||
load->magic = 0;
|
||||
ISC_MAGIC_CLEAR(load);
|
||||
dns_db_detach(&load->db);
|
||||
zone_idetach(&load->zone);
|
||||
zone_idetach(&load->callbacks.zone);
|
||||
@@ -3402,7 +3403,7 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) {
|
||||
*/
|
||||
nsec3chain = isc_mem_get(zone->mctx, sizeof *nsec3chain);
|
||||
|
||||
nsec3chain->magic = 0;
|
||||
ISC_MAGIC_CLEAR(nsec3chain);
|
||||
nsec3chain->done = false;
|
||||
nsec3chain->db = NULL;
|
||||
nsec3chain->dbiterator = NULL;
|
||||
@@ -11635,7 +11636,7 @@ notify_create(isc_mem_t *mctx, unsigned int flags, dns_notify_t **notifyp) {
|
||||
isc_sockaddr_any(¬ify->dst);
|
||||
dns_name_init(¬ify->ns, NULL);
|
||||
ISC_LINK_INIT(notify, link);
|
||||
notify->magic = NOTIFY_MAGIC;
|
||||
ISC_MAGIC_INIT(notify, NOTIFY_MAGIC);
|
||||
*notifyp = notify;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -12494,7 +12495,7 @@ stub_callback(isc_task_t *task, isc_event_t *event) {
|
||||
|
||||
free_stub:
|
||||
UNLOCK_ZONE(zone);
|
||||
stub->magic = 0;
|
||||
ISC_MAGIC_CLEAR(stub);
|
||||
dns_zone_idetach(&stub->zone);
|
||||
INSIST(stub->db == NULL);
|
||||
INSIST(stub->version == NULL);
|
||||
@@ -13335,7 +13336,7 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
|
||||
|
||||
if (stub == NULL) {
|
||||
stub = isc_mem_get(zone->mctx, sizeof(*stub));
|
||||
stub->magic = STUB_MAGIC;
|
||||
ISC_MAGIC_INIT(stub, STUB_MAGIC);
|
||||
stub->mctx = zone->mctx;
|
||||
stub->zone = NULL;
|
||||
stub->db = NULL;
|
||||
@@ -13522,7 +13523,7 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
|
||||
cleanup:
|
||||
cancel_refresh(zone);
|
||||
if (stub != NULL) {
|
||||
stub->magic = 0;
|
||||
ISC_MAGIC_CLEAR(stub);
|
||||
if (stub->version != NULL)
|
||||
dns_db_closeversion(stub->db, &stub->version,
|
||||
false);
|
||||
@@ -16266,7 +16267,7 @@ zone_loaddone(void *arg, isc_result_t result) {
|
||||
UNLOCK_ZONE(secure);
|
||||
UNLOCK_ZONE(zone);
|
||||
|
||||
load->magic = 0;
|
||||
ISC_MAGIC_CLEAR(load);
|
||||
dns_db_detach(&load->db);
|
||||
if (load->zone->lctx != NULL)
|
||||
dns_loadctx_detach(&load->zone->lctx);
|
||||
@@ -16558,7 +16559,7 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) {
|
||||
static void
|
||||
forward_destroy(dns_forward_t *forward) {
|
||||
|
||||
forward->magic = 0;
|
||||
ISC_MAGIC_CLEAR(forward);
|
||||
if (forward->request != NULL)
|
||||
dns_request_destroy(&forward->request);
|
||||
if (forward->msgbuf != NULL)
|
||||
@@ -16758,7 +16759,7 @@ dns_zone_forwardupdate(dns_zone_t *zone, dns_message_t *msg,
|
||||
forward->callback = callback;
|
||||
forward->callback_arg = callback_arg;
|
||||
ISC_LINK_INIT(forward, link);
|
||||
forward->magic = FORWARD_MAGIC;
|
||||
ISC_MAGIC_INIT(forward, FORWARD_MAGIC);
|
||||
forward->options = DNS_REQUESTOPT_TCP;
|
||||
/*
|
||||
* If we have a SIG(0) signed message we need to preserve the
|
||||
@@ -16899,7 +16900,7 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
||||
|
||||
isc_mutex_init(&zmgr->iolock);
|
||||
|
||||
zmgr->magic = ZONEMGR_MAGIC;
|
||||
ISC_MAGIC_INIT(zmgr, ZONEMGR_MAGIC);
|
||||
|
||||
*zmgrp = zmgr;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -17238,7 +17239,7 @@ zonemgr_free(dns_zonemgr_t *zmgr) {
|
||||
INSIST(zmgr->refs == 0);
|
||||
INSIST(ISC_LIST_EMPTY(zmgr->zones));
|
||||
|
||||
zmgr->magic = 0;
|
||||
ISC_MAGIC_CLEAR(zmgr);
|
||||
|
||||
isc_mutex_destroy(&zmgr->iolock);
|
||||
isc_ratelimiter_detach(&zmgr->notifyrl);
|
||||
@@ -17472,7 +17473,7 @@ zonemgr_getio(dns_zonemgr_t *zmgr, bool high,
|
||||
io->task = NULL;
|
||||
isc_task_attach(task, &io->task);
|
||||
ISC_LINK_INIT(io, link);
|
||||
io->magic = IO_MAGIC;
|
||||
ISC_MAGIC_INIT(io, IO_MAGIC);
|
||||
|
||||
LOCK(&zmgr->iolock);
|
||||
zmgr->ioactive++;
|
||||
@@ -17508,7 +17509,7 @@ zonemgr_putio(dns_io_t **iop) {
|
||||
|
||||
zmgr = io->zmgr;
|
||||
isc_task_detach(&io->task);
|
||||
io->magic = 0;
|
||||
ISC_MAGIC_CLEAR(io);
|
||||
isc_mem_put(zmgr->mctx, io, sizeof(*io));
|
||||
|
||||
LOCK(&zmgr->iolock);
|
||||
@@ -18234,7 +18235,7 @@ zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm, uint16_t keyid,
|
||||
|
||||
signing = isc_mem_get(zone->mctx, sizeof *signing);
|
||||
|
||||
signing->magic = 0;
|
||||
ISC_MAGIC_CLEAR(signing);
|
||||
signing->db = NULL;
|
||||
signing->dbiterator = NULL;
|
||||
signing->algorithm = algorithm;
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ struct zt_load_params {
|
||||
|
||||
struct dns_zt {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
dns_rdataclass_t rdclass;
|
||||
isc_rwlock_t rwlock;
|
||||
@@ -98,7 +98,7 @@ dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) {
|
||||
isc_refcount_init(&zt->references, 1);
|
||||
atomic_init(&zt->flush, false);
|
||||
zt->rdclass = rdclass;
|
||||
zt->magic = ZTMAGIC;
|
||||
ISC_MAGIC_INIT(zt, ZTMAGIC);
|
||||
zt->loaddone = NULL;
|
||||
zt->loaddone_arg = NULL;
|
||||
zt->loadparams = NULL;
|
||||
@@ -229,7 +229,7 @@ zt_destroy(dns_zt_t *zt) {
|
||||
}
|
||||
dns_rbt_destroy(&zt->table);
|
||||
isc_rwlock_destroy(&zt->rwlock);
|
||||
zt->magic = 0;
|
||||
ISC_MAGIC_CLEAR(zt);
|
||||
isc_mem_putanddetach(&zt->mctx, zt, sizeof(*zt));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -53,7 +53,7 @@ struct irs_context {
|
||||
* An IRS context is a thread-specific object, and does not need to
|
||||
* be locked.
|
||||
*/
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_appctx_t *actx;
|
||||
isc_taskmgr_t *taskmgr;
|
||||
@@ -262,7 +262,7 @@ irs_context_create(irs_context_t **contextp) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
context->magic = IRS_CONTEXT_MAGIC;
|
||||
ISC_MAGIC_INIT(context, IRS_CONTEXT_MAGIC);
|
||||
*contextp = context;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -298,7 +298,7 @@ irs_context_destroy(irs_context_t **contextp) {
|
||||
ctxs_destroy(NULL, &context->actx, &context->taskmgr,
|
||||
&context->socketmgr, &context->timermgr);
|
||||
|
||||
context->magic = 0;
|
||||
ISC_MAGIC_CLEAR(context);
|
||||
|
||||
isc_mem_putanddetach(&context->mctx, context, sizeof(*context));
|
||||
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
struct irs_dnsconf {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
irs_dnsconf_dnskeylist_t trusted_keylist;
|
||||
};
|
||||
@@ -265,7 +265,7 @@ irs_dnsconf_load(isc_mem_t *mctx, const char *filename, irs_dnsconf_t **confp)
|
||||
cfg_parser_destroy(&parser);
|
||||
}
|
||||
|
||||
conf->magic = IRS_DNSCONF_MAGIC;
|
||||
ISC_MAGIC_INIT(conf, IRS_DNSCONF_MAGIC);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
*confp = conf;
|
||||
|
||||
+2
-2
@@ -88,7 +88,7 @@ struct irs_resconf {
|
||||
* The configuration data is a thread-specific object, and does not
|
||||
* need to be locked.
|
||||
*/
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
isc_sockaddrlist_t nameservers;
|
||||
@@ -583,7 +583,7 @@ irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp)
|
||||
}
|
||||
|
||||
error:
|
||||
conf->magic = IRS_RESCONF_MAGIC;
|
||||
ISC_MAGIC_INIT(conf, IRS_RESCONF_MAGIC);
|
||||
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
irs_resconf_destroy(&conf);
|
||||
|
||||
+3
-3
@@ -77,7 +77,7 @@ enum {
|
||||
#endif /* WIN32 */
|
||||
|
||||
struct isc_appctx {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_mutex_t lock;
|
||||
isc_eventlist_t on_run;
|
||||
@@ -543,7 +543,7 @@ isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
|
||||
|
||||
ctx = isc_mem_get(mctx, sizeof(*ctx));
|
||||
|
||||
ctx->magic = APPCTX_MAGIC;
|
||||
ISC_MAGIC_INIT(ctx, APPCTX_MAGIC);
|
||||
|
||||
ctx->mctx = NULL;
|
||||
isc_mem_attach(mctx, &ctx->mctx);
|
||||
@@ -562,7 +562,7 @@ isc_appctx_destroy(isc_appctx_t **ctxp) {
|
||||
*ctxp = NULL;
|
||||
REQUIRE(VALID_APPCTX(ctx));
|
||||
|
||||
ctx->magic = 0;
|
||||
ISC_MAGIC_CLEAR(ctx);
|
||||
|
||||
isc_mem_putanddetach(&ctx->mctx, ctx, sizeof(*ctx));
|
||||
}
|
||||
|
||||
+4
-4
@@ -25,8 +25,8 @@
|
||||
#define VALID_COUNTER(r) ISC_MAGIC_VALID(r, COUNTER_MAGIC)
|
||||
|
||||
struct isc_counter {
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_refcount_t references;
|
||||
atomic_uint_fast32_t limit;
|
||||
atomic_uint_fast32_t used;
|
||||
@@ -47,7 +47,7 @@ isc_counter_create(isc_mem_t *mctx, int limit, isc_counter_t **counterp) {
|
||||
atomic_init(&counter->limit, limit);
|
||||
atomic_init(&counter->used, 0);
|
||||
|
||||
counter->magic = COUNTER_MAGIC;
|
||||
ISC_MAGIC_INIT(counter, COUNTER_MAGIC);
|
||||
*counterp = counter;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ isc_counter_attach(isc_counter_t *source, isc_counter_t **targetp) {
|
||||
|
||||
static void
|
||||
destroy(isc_counter_t *counter) {
|
||||
counter->magic = 0;
|
||||
ISC_MAGIC_CLEAR(counter);
|
||||
isc_mem_putanddetach(&counter->mctx, counter, sizeof(*counter));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@
|
||||
|
||||
/*% ISC heap structure. */
|
||||
struct isc_heap {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
unsigned int size;
|
||||
unsigned int size_increment;
|
||||
@@ -88,7 +88,7 @@ isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare,
|
||||
REQUIRE(compare != NULL);
|
||||
|
||||
heap = isc_mem_get(mctx, sizeof(*heap));
|
||||
heap->magic = HEAP_MAGIC;
|
||||
ISC_MAGIC_INIT(heap, HEAP_MAGIC);
|
||||
heap->size = 0;
|
||||
heap->mctx = NULL;
|
||||
isc_mem_attach(mctx, &heap->mctx);
|
||||
@@ -117,7 +117,7 @@ isc_heap_destroy(isc_heap_t **heapp) {
|
||||
if (heap->array != NULL)
|
||||
isc_mem_put(heap->mctx, heap->array,
|
||||
heap->size * sizeof(void *));
|
||||
heap->magic = 0;
|
||||
ISC_MAGIC_CLEAR(heap);
|
||||
isc_mem_putanddetach(&heap->mctx, heap, sizeof(*heap));
|
||||
|
||||
*heapp = NULL;
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ struct isc_ht_node {
|
||||
};
|
||||
|
||||
struct isc_ht {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
size_t size;
|
||||
size_t mask;
|
||||
@@ -72,7 +72,7 @@ isc_ht_init(isc_ht_t **htp, isc_mem_t *mctx, uint8_t bits) {
|
||||
ht->table[i] = NULL;
|
||||
}
|
||||
|
||||
ht->magic = ISC_HT_MAGIC;
|
||||
ISC_MAGIC_INIT(ht, ISC_HT_MAGIC);
|
||||
|
||||
*htp = ht;
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -90,7 +90,7 @@ isc_ht_destroy(isc_ht_t **htp) {
|
||||
|
||||
REQUIRE(ISC_HT_VALID(ht));
|
||||
|
||||
ht->magic = 0;
|
||||
ISC_MAGIC_CLEAR(ht);
|
||||
|
||||
for (i = 0; i < ht->size; i++) {
|
||||
isc_ht_node_t *node = ht->table[i];
|
||||
|
||||
@@ -171,7 +171,7 @@ ISC_LANG_BEGINDECLS
|
||||
*/
|
||||
|
||||
struct isc_buffer {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
void *base;
|
||||
/*@{*/
|
||||
/*! The following integers are byte offsets from 'base'. */
|
||||
|
||||
@@ -9,18 +9,21 @@
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef ISC_MAGIC_H
|
||||
#define ISC_MAGIC_H 1
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <isc/atomic.h>
|
||||
#include <isc/likely.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
/*! \file isc/magic.h */
|
||||
|
||||
typedef struct {
|
||||
unsigned int magic;
|
||||
} isc__magic_t;
|
||||
typedef atomic_uint_fast32_t isc_magic_t;
|
||||
|
||||
typedef struct {
|
||||
isc_magic_t magic;
|
||||
} isc__magic_t;
|
||||
|
||||
/*%
|
||||
* To use this macro the magic number MUST be the first thing in the
|
||||
@@ -28,9 +31,36 @@ typedef struct {
|
||||
* The intent of this is to allow magic numbers to be checked even though
|
||||
* the object is otherwise opaque.
|
||||
*/
|
||||
#define ISC_MAGIC_VALID(a,b) (ISC_LIKELY((a) != NULL) && \
|
||||
ISC_LIKELY(((const isc__magic_t *)(a))->magic == (b)))
|
||||
|
||||
#if (defined(__clang__) && __clang_major__ < 8) || ISC_MUTEX_ATOMICS
|
||||
#define CONST_ATOMIC 0
|
||||
#else
|
||||
#define CONST_ATOMIC 1
|
||||
#endif
|
||||
|
||||
#if CONST_ATOMIC
|
||||
#define ISC_MAGIC_VALID(o, v) \
|
||||
(ISC_LIKELY((o) != NULL) && \
|
||||
ISC_LIKELY(isc_magic_valid((const isc__magic_t *)(o), (v))))
|
||||
|
||||
static inline bool
|
||||
isc_magic_valid(const isc__magic_t *obj, uint_fast32_t val) {
|
||||
isc__magic_t *magic;
|
||||
DE_CONST((const void *)obj, magic);
|
||||
return (atomic_load_acquire(&magic->magic) == val);
|
||||
}
|
||||
#else /* CONST_ATOMIC */
|
||||
#define ISC_MAGIC_VALID(o, v) \
|
||||
(ISC_LIKELY((o) != NULL) && \
|
||||
ISC_LIKELY(atomic_load_acquire(&((const isc__magic_t *)(o))->magic) == (v)))
|
||||
#endif /* CONST_ATOMIC */
|
||||
|
||||
#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
|
||||
|
||||
#endif /* ISC_MAGIC_H */
|
||||
#define ISC_MAGIC_INIT(o, v) atomic_init(&(o)->magic, (v))
|
||||
|
||||
#define ISC_MAGIC_CLEAR(o) atomic_store_release(&(o)->magic, 0)
|
||||
|
||||
#define ISC_IMPMAGIC_INIT(o, v) atomic_init(&(o)->impmagic, (v))
|
||||
|
||||
#define ISC_IMPMAGIC_CLEAR(o) atomic_store_release(&(o)->impmagic, 0)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
@@ -184,8 +185,8 @@ typedef struct isc_memmethods {
|
||||
* invariants.
|
||||
*/
|
||||
struct isc_mem {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
isc_memmethods_t *methods;
|
||||
};
|
||||
|
||||
@@ -198,8 +199,8 @@ struct isc_mem {
|
||||
* that for the mem structure applies.
|
||||
*/
|
||||
struct isc_mempool {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_MPOOL_MAGIC ISC_MAGIC('A','m','p','l')
|
||||
|
||||
@@ -95,11 +95,11 @@ typedef struct isc_radix_node {
|
||||
or -1 for glue nodes */
|
||||
} isc_radix_node_t;
|
||||
|
||||
#define RADIX_TREE_MAGIC ISC_MAGIC('R','d','x','T');
|
||||
#define RADIX_TREE_VALID(a) ISC_MAGIC_VALID(a, RADIX_TREE_MAGIC);
|
||||
#define RADIX_TREE_MAGIC ISC_MAGIC('R','d','x','T')
|
||||
#define RADIX_TREE_VALID(a) ISC_MAGIC_VALID(a, RADIX_TREE_MAGIC)
|
||||
|
||||
typedef struct isc_radix_tree {
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_radix_node_t *head;
|
||||
uint32_t maxbits; /* for IP, 32 bit addresses */
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <isc/atomic.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
@@ -43,7 +44,7 @@ struct isc_rwlock {
|
||||
|
||||
struct isc_rwlock {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mutex_t lock;
|
||||
atomic_int_fast32_t spins;
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <isc/event.h>
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/region.h>
|
||||
#include <isc/sockaddr.h>
|
||||
#include <isc/time.h>
|
||||
@@ -287,8 +288,8 @@ typedef enum {
|
||||
*/
|
||||
#ifndef WIN32
|
||||
struct isc_socketmgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -302,8 +303,8 @@ struct isc_socketmgr {
|
||||
*/
|
||||
#ifndef WIN32
|
||||
struct isc_socket {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ typedef enum {
|
||||
* all task invariants.
|
||||
*/
|
||||
struct isc_taskmgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A','t','m','g')
|
||||
@@ -124,8 +124,8 @@ struct isc_taskmgr {
|
||||
* that for the taskmgr structure applies.
|
||||
*/
|
||||
struct isc_task {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASK_MAGIC ISC_MAGIC('A','t','s','t')
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
#include <isc/event.h>
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/time.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
@@ -109,8 +110,8 @@ typedef struct isc_timerevent {
|
||||
* all timer invariants.
|
||||
*/
|
||||
struct isc_timermgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
|
||||
@@ -122,8 +123,8 @@ struct isc_timermgr {
|
||||
* that for the timermgr structure applies.
|
||||
*/
|
||||
struct isc_timer {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_magic_t impmagic;
|
||||
isc_magic_t magic;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ typedef struct inputsource {
|
||||
|
||||
struct isc_lex {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_magic_t magic;
|
||||
isc_mem_t * mctx;
|
||||
size_t max_token;
|
||||
char * data;
|
||||
@@ -102,7 +102,7 @@ isc_lex_create(isc_mem_t *mctx, size_t max_token, isc_lex_t **lexp) {
|
||||
lex->saved_paren_count = 0;
|
||||
memset(lex->specials, 0, 256);
|
||||
INIT_LIST(lex->sources);
|
||||
lex->magic = LEX_MAGIC;
|
||||
ISC_MAGIC_INIT(lex, LEX_MAGIC);
|
||||
|
||||
*lexp = lex;
|
||||
|
||||
@@ -125,7 +125,7 @@ isc_lex_destroy(isc_lex_t **lexp) {
|
||||
RUNTIME_CHECK(isc_lex_close(lex) == ISC_R_SUCCESS);
|
||||
if (lex->data != NULL)
|
||||
isc_mem_put(lex->mctx, lex->data, lex->max_token + 1);
|
||||
lex->magic = 0;
|
||||
ISC_MAGIC_CLEAR(lex);
|
||||
isc_mem_put(lex->mctx, lex, sizeof(*lex));
|
||||
|
||||
*lexp = NULL;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user