Commit b77f76be authored by David Lawrence's avatar David Lawrence
Browse files

Where the methods field of an rdataset was compared to NULL, now use

 dns_rdataset_isassociated() instead.
parent b905ff7c
......@@ -341,7 +341,7 @@ query_putrdataset(ns_client_t *client, dns_rdataset_t **rdatasetp) {
CTRACE("query_putrdataset");
if (rdataset != NULL) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
dns_message_puttemprdataset(client->message, rdatasetp);
}
......@@ -610,9 +610,9 @@ query_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
rdataset, sigrdataset);
if (result == DNS_R_DELEGATION ||
result == ISC_R_NOTFOUND) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset->methods != NULL)
if (dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
if (is_zone) {
if (USECACHE(client)) {
......@@ -631,9 +631,9 @@ query_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
* We don't have the data in the cache. If we've got
* glue from the zone, use it.
*/
if (zrdataset.methods != NULL) {
if (dns_rdataset_isassociated(&zrdataset)) {
dns_rdataset_clone(&zrdataset, rdataset);
if (zsigrdataset.methods != NULL)
if (dns_rdataset_isassociated(&zsigrdataset))
dns_rdataset_clone(&zsigrdataset,
sigrdataset);
result = ISC_R_SUCCESS;
......@@ -654,7 +654,7 @@ query_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
version = NULL;
dns_rdataset_clone(rdataset, &zrdataset);
dns_rdataset_disassociate(rdataset);
if (sigrdataset->methods != NULL) {
if (dns_rdataset_isassociated(sigrdataset)) {
dns_rdataset_clone(sigrdataset, &zsigrdataset);
dns_rdataset_disassociate(sigrdataset);
}
......@@ -667,17 +667,17 @@ query_simplefind(void *arg, dns_name_t *name, dns_rdatatype_t type,
*/
result = ISC_R_SUCCESS;
} else if (result != ISC_R_SUCCESS) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset->methods != NULL)
if (dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
result = ISC_R_NOTFOUND;
}
cleanup:
if (zrdataset.methods != NULL) {
if (dns_rdataset_isassociated(&zrdataset)) {
dns_rdataset_disassociate(&zrdataset);
if (zsigrdataset.methods != NULL)
if (dns_rdataset_isassociated(&zsigrdataset))
dns_rdataset_disassociate(&zsigrdataset);
}
if (db != NULL)
......@@ -896,7 +896,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
query_keepname(client, fname, dbuf);
mname = NULL;
if (rdataset->methods != NULL &&
if (dns_rdataset_isassociated(rdataset) &&
!query_isduplicate(client, fname, type, &mname)) {
if (mname != NULL) {
query_releasename(client, &fname);
......@@ -912,7 +912,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
* so we do not need to check if the SIG rdataset is already
* in the response.
*/
if (sigrdataset->methods != NULL) {
if (dns_rdataset_isassociated(sigrdataset)) {
ISC_LIST_APPEND(fname->list, sigrdataset, link);
sigrdataset = NULL;
}
......@@ -929,7 +929,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
* XXXRTH This code could be more efficient.
*/
if (rdataset != NULL) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
} else {
rdataset = query_newrdataset(client);
......@@ -937,7 +937,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
goto addname;
}
if (sigrdataset != NULL) {
if (sigrdataset->methods != NULL)
if (dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
} else {
sigrdataset = query_newrdataset(client);
......@@ -955,7 +955,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
/*
* Negative cache entries don't have sigrdatasets.
*/
INSIST(sigrdataset->methods == NULL);
INSIST(! dns_rdataset_isassociated(sigrdataset));
}
if (zdb != NULL && result == ISC_R_NOTFOUND) {
/*
......@@ -979,7 +979,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
need_addname = ISC_TRUE;
ISC_LIST_APPEND(fname->list, rdataset, link);
added_something = ISC_TRUE;
if (sigrdataset->methods != NULL) {
if (dns_rdataset_isassociated(sigrdataset)) {
ISC_LIST_APPEND(fname->list,
sigrdataset, link);
sigrdataset =
......@@ -990,7 +990,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
goto addname;
} else {
dns_rdataset_disassociate(rdataset);
if (sigrdataset->methods != NULL)
if (dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
}
}
......@@ -1002,7 +1002,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
goto addname;
if (result == DNS_R_NCACHENXRRSET) {
dns_rdataset_disassociate(rdataset);
INSIST(sigrdataset->methods == NULL);
INSIST(! dns_rdataset_isassociated(sigrdataset));
}
if (zdb != NULL && result == ISC_R_NOTFOUND) {
/*
......@@ -1027,7 +1027,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
a6rdataset = rdataset;
ISC_LIST_APPEND(fname->list, rdataset, link);
added_something = ISC_TRUE;
if (sigrdataset->methods != NULL) {
if (dns_rdataset_isassociated(sigrdataset)) {
ISC_LIST_APPEND(fname->list,
sigrdataset, link);
sigrdataset =
......@@ -1047,7 +1047,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
goto addname;
if (result == DNS_R_NCACHENXRRSET) {
dns_rdataset_disassociate(rdataset);
INSIST(sigrdataset->methods == NULL);
INSIST(! dns_rdataset_isassociated(sigrdataset));
}
if (zdb != NULL && result == ISC_R_NOTFOUND) {
/*
......@@ -1071,7 +1071,7 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) {
need_addname = ISC_TRUE;
ISC_LIST_APPEND(fname->list, rdataset, link);
added_something = ISC_TRUE;
if (sigrdataset->methods != NULL) {
if (dns_rdataset_isassociated(sigrdataset)) {
ISC_LIST_APPEND(fname->list,
sigrdataset, link);
sigrdataset = NULL;
......@@ -1204,7 +1204,7 @@ query_adda6rrset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset,
if (dns_name_concatenate(name, NULL, fname, NULL) != ISC_R_SUCCESS)
goto cleanup;
dns_rdataset_clone(rdataset, crdataset);
if (sigrdataset->methods != NULL)
if (dns_rdataset_isassociated(sigrdataset))
dns_rdataset_clone(sigrdataset, csigrdataset);
mname = NULL;
......@@ -1226,7 +1226,7 @@ query_adda6rrset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset,
* we do not need to check if the SIG rdataset is already in the
* response.
*/
if (csigrdataset->methods != NULL) {
if (dns_rdataset_isassociated(csigrdataset)) {
ISC_LIST_APPEND(fname->list, csigrdataset, link);
csigrdataset = NULL;
}
......@@ -1346,7 +1346,7 @@ query_addrrset(ns_client_t *client, dns_name_t **namep,
*/
query_addrdataset(client, mname, rdataset);
*rdatasetp = NULL;
if (sigrdataset != NULL && sigrdataset->methods != NULL) {
if (sigrdataset != NULL && dns_rdataset_isassociated(sigrdataset)) {
/*
* We have a signature. Add it to the response.
*/
......
......@@ -372,10 +372,11 @@ dns_db_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
REQUIRE(nodep == NULL || (nodep != NULL && *nodep == NULL));
REQUIRE(dns_name_hasbuffer(foundname));
REQUIRE(rdataset == NULL ||
(DNS_RDATASET_VALID(rdataset) && rdataset->methods == NULL));
(DNS_RDATASET_VALID(rdataset) &&
! dns_rdataset_isassociated(rdataset)));
REQUIRE(sigrdataset == NULL ||
(DNS_RDATASET_VALID(sigrdataset) &&
sigrdataset->methods == NULL));
! dns_rdataset_isassociated(sigrdataset)));
return ((db->methods->find)(db, name, version, type, options, now,
nodep, foundname, rdataset, sigrdataset));
......@@ -397,7 +398,7 @@ dns_db_findzonecut(dns_db_t *db, dns_name_t *name,
REQUIRE(dns_name_hasbuffer(foundname));
REQUIRE(sigrdataset == NULL ||
(DNS_RDATASET_VALID(sigrdataset) &&
sigrdataset->methods == NULL));
! dns_rdataset_isassociated(sigrdataset)));
return ((db->methods->findzonecut)(db, name, options, now, nodep,
foundname, rdataset, sigrdataset));
......@@ -495,12 +496,12 @@ dns_db_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
REQUIRE(DNS_DB_VALID(db));
REQUIRE(node != NULL);
REQUIRE(DNS_RDATASET_VALID(rdataset));
REQUIRE(rdataset->methods == NULL);
REQUIRE(! dns_rdataset_isassociated(rdataset));
REQUIRE(covers == 0 || type == dns_rdatatype_sig);
REQUIRE(type != dns_rdatatype_any);
REQUIRE(sigrdataset == NULL ||
(DNS_RDATASET_VALID(sigrdataset) &&
sigrdataset->methods == NULL));
! dns_rdataset_isassociated(sigrdataset)));
return ((db->methods->findrdataset)(db, node, version, type, covers,
now, rdataset, sigrdataset));
......@@ -537,11 +538,11 @@ dns_db_addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
((db->attributes & DNS_DBATTR_CACHE) != 0 &&
version == NULL && (options & DNS_DBADD_MERGE) == 0));
REQUIRE(DNS_RDATASET_VALID(rdataset));
REQUIRE(rdataset->methods != NULL);
REQUIRE(dns_rdataset_isassociated(rdataset));
REQUIRE(rdataset->rdclass == db->rdclass);
REQUIRE(addedrdataset == NULL ||
(DNS_RDATASET_VALID(addedrdataset) &&
addedrdataset->methods == NULL));
! dns_rdataset_isassociated(addedrdataset)));
return ((db->methods->addrdataset)(db, node, version, now, rdataset,
options, addedrdataset));
......@@ -561,11 +562,11 @@ dns_db_subtractrdataset(dns_db_t *db, dns_dbnode_t *node,
REQUIRE(node != NULL);
REQUIRE((db->attributes & DNS_DBATTR_CACHE) == 0 && version != NULL);
REQUIRE(DNS_RDATASET_VALID(rdataset));
REQUIRE(rdataset->methods != NULL);
REQUIRE(dns_rdataset_isassociated(rdataset));
REQUIRE(rdataset->rdclass == db->rdclass);
REQUIRE(newrdataset == NULL ||
(DNS_RDATASET_VALID(newrdataset) &&
newrdataset->methods == NULL));
! dns_rdataset_isassociated(newrdataset)));
return ((db->methods->subtractrdataset)(db, node, version, rdataset,
newrdataset));
......
......@@ -67,7 +67,7 @@ dns_rdatalist_tordataset(dns_rdatalist_t *rdatalist,
REQUIRE(rdatalist != NULL);
REQUIRE(DNS_RDATASET_VALID(rdataset));
REQUIRE(rdataset->methods == NULL);
REQUIRE(! dns_rdataset_isassociated(rdataset));
rdataset->methods = &methods;
rdataset->rdclass = rdatalist->rdclass;
......
......@@ -62,7 +62,7 @@ dns_rdatasetiter_next(dns_rdatasetiter_t *iterator) {
}
void
dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
dns_rdataset_t *rdataset)
{
/*
......@@ -71,7 +71,7 @@ dns_rdatasetiter_current(dns_rdatasetiter_t *iterator,
REQUIRE(DNS_RDATASETITER_VALID(iterator));
REQUIRE(DNS_RDATASET_VALID(rdataset));
REQUIRE(rdataset->methods == NULL);
REQUIRE(! dns_rdataset_isassociated(rdataset));
iterator->methods->current(iterator, rdataset);
}
......@@ -618,9 +618,10 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
if (result == DNS_R_DELEGATION ||
result == ISC_R_NOTFOUND) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL && sigrdataset->methods != NULL)
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
if (is_zone) {
if (view->cachedb != NULL) {
......@@ -639,10 +640,10 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
* We don't have the data in the cache. If we've got
* glue from the zone, use it.
*/
if (zrdataset.methods != NULL) {
if (dns_rdataset_isassociated(&zrdataset)) {
dns_rdataset_clone(&zrdataset, rdataset);
if (sigrdataset != NULL &&
zsigrdataset.methods != NULL)
dns_rdataset_isassociated(&zsigrdataset))
dns_rdataset_clone(&zsigrdataset,
sigrdataset);
result = DNS_R_GLUE;
......@@ -664,7 +665,7 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
dns_rdataset_clone(rdataset, &zrdataset);
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL &&
sigrdataset->methods != NULL) {
dns_rdataset_isassociated(sigrdataset)) {
dns_rdataset_clone(sigrdataset, &zsigrdataset);
dns_rdataset_disassociate(sigrdataset);
}
......@@ -679,9 +680,10 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
}
if (result == ISC_R_NOTFOUND && use_hints && view->hints != NULL) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL && sigrdataset->methods != NULL)
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
result = dns_db_find(view->hints, name, NULL, type, options,
now, NULL, foundname,
......@@ -703,15 +705,16 @@ dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
/*
* We don't care about any DNSSEC proof data in these cases.
*/
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL && sigrdataset->methods != NULL)
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
}
if (zrdataset.methods != NULL) {
if (dns_rdataset_isassociated(&zrdataset)) {
dns_rdataset_disassociate(&zrdataset);
if (zsigrdataset.methods != NULL)
if (dns_rdataset_isassociated(&zsigrdataset))
dns_rdataset_disassociate(&zsigrdataset);
}
if (db != NULL)
......@@ -742,9 +745,10 @@ dns_view_simplefind(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
* foundname is not returned by this simplified API. We
* disassociate them here to prevent any misuse by the caller.
*/
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL && sigrdataset->methods != NULL)
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
} else if (result != ISC_R_SUCCESS &&
result != DNS_R_GLUE &&
......@@ -753,9 +757,10 @@ dns_view_simplefind(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
result != DNS_R_NCACHENXRRSET &&
result != DNS_R_NXRRSET &&
result != ISC_R_NOTFOUND) {
if (rdataset->methods != NULL)
if (dns_rdataset_isassociated(rdataset))
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL && sigrdataset->methods != NULL)
if (sigrdataset != NULL &&
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
result = ISC_R_NOTFOUND;
}
......@@ -852,7 +857,7 @@ dns_view_findzonecut(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
dns_rdataset_clone(rdataset, &zrdataset);
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL &&
sigrdataset->methods != NULL) {
dns_rdataset_isassociated(sigrdataset)) {
dns_rdataset_clone(sigrdataset, &zsigrdataset);
dns_rdataset_disassociate(sigrdataset);
}
......@@ -896,17 +901,18 @@ dns_view_findzonecut(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
finish:
if (use_zone) {
if (rdataset->methods != NULL) {
if (dns_rdataset_isassociated(rdataset)) {
dns_rdataset_disassociate(rdataset);
if (sigrdataset != NULL &&
sigrdataset->methods != NULL)
dns_rdataset_isassociated(sigrdataset))
dns_rdataset_disassociate(sigrdataset);
}
result = dns_name_concatenate(zfname, NULL, fname, NULL);
if (result != ISC_R_SUCCESS)
goto cleanup;
dns_rdataset_clone(&zrdataset, rdataset);
if (sigrdataset != NULL && zrdataset.methods != NULL)
if (sigrdataset != NULL &&
dns_rdataset_isassociated(&zrdataset))
dns_rdataset_clone(&zsigrdataset, sigrdataset);
} else if (try_hints && use_hints && view->hints != NULL) {
/*
......@@ -925,9 +931,9 @@ dns_view_findzonecut(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
}
cleanup:
if (zrdataset.methods != NULL) {
if (dns_rdataset_isassociated(&zrdataset)) {
dns_rdataset_disassociate(&zrdataset);
if (zsigrdataset.methods != NULL)
if (dns_rdataset_isassociated(&zsigrdataset))
dns_rdataset_disassociate(&zsigrdataset);
}
if (db != NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment