2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 23:55:27 +00:00

fix some locking problems

This commit is contained in:
Bob Halley
1999-04-05 23:59:26 +00:00
parent 21f835803a
commit 0990426ddf

View File

@@ -902,6 +902,10 @@ zone_zonecut_callback(dns_rbtnode_t *node, dns_name_t *name, void *arg) {
} }
if (found != NULL) { if (found != NULL) {
/*
* We increment the reference count on node to ensure that
* search->zonecut_rdataset will still be valid later.
*/
new_reference(search->rbtdb, node); new_reference(search->rbtdb, node);
search->zonecut = node; search->zonecut = node;
search->zonecut_rdataset = found; search->zonecut_rdataset = found;
@@ -991,11 +995,16 @@ setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
{ {
dns_result_t result; dns_result_t result;
dns_name_t *zcname; dns_name_t *zcname;
dns_rdatatype_t type;
dns_rbtnode_t *node;
/* /*
* Caller must be holding the node lock. * The caller MUST NOT be holding any node locks.
*/ */
node = search->zonecut;
type = search->zonecut_rdataset->type;
/* /*
* If we have to set foundname, we do it before anything else. * If we have to set foundname, we do it before anything else.
* If we were to set foundname after we had set nodep or bound the * If we were to set foundname after we had set nodep or bound the
@@ -1015,14 +1024,17 @@ setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
* count here because we're going to use the reference we * count here because we're going to use the reference we
* already have in the search block. * already have in the search block.
*/ */
*nodep = search->zonecut; *nodep = node;
search->need_cleanup = ISC_FALSE; search->need_cleanup = ISC_FALSE;
} }
if (rdataset != NULL) if (rdataset != NULL) {
bind_rdataset(search->rbtdb, search->zonecut, LOCK(&(search->rbtdb->node_locks[node->locknum].lock));
search->zonecut_rdataset, rdataset); bind_rdataset(search->rbtdb, node, search->zonecut_rdataset,
rdataset);
UNLOCK(&(search->rbtdb->node_locks[node->locknum].lock));
}
if (rdataset->type == dns_rdatatype_dname) if (type == dns_rdatatype_dname)
return (DNS_R_DNAME); return (DNS_R_DNAME);
return (DNS_R_DELEGATION); return (DNS_R_DELEGATION);
} }
@@ -1086,10 +1098,8 @@ zone_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
if (result == DNS_R_PARTIALMATCH) { if (result == DNS_R_PARTIALMATCH) {
partial_match: partial_match:
if (search.zonecut != NULL) { if (search.zonecut != NULL) {
LOCK(&(search.rbtdb->node_locks[node->locknum].lock));
result = setup_delegation(&search, nodep, foundname, result = setup_delegation(&search, nodep, foundname,
rdataset); rdataset);
UNLOCK(&(search.rbtdb->node_locks[node->locknum].lock));
goto tree_exit; goto tree_exit;
} else { } else {
/* /*
@@ -1185,6 +1195,11 @@ zone_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
*/ */
if (maybe_zonecut && if (maybe_zonecut &&
header->type == dns_rdatatype_ns) { header->type == dns_rdatatype_ns) {
/*
* We increment the reference count on node to
* ensure that search->zonecut_rdataset will
* still be valid later.
*/
new_reference(search.rbtdb, node); new_reference(search.rbtdb, node);
search.zonecut = node; search.zonecut = node;
search.zonecut_rdataset = header; search.zonecut_rdataset = header;
@@ -1255,17 +1270,19 @@ zone_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
*/ */
result = DNS_R_BADDB; result = DNS_R_BADDB;
} else if (search.zonecut != NULL) { } else if (search.zonecut != NULL) {
/* /*
* We were trying to find glue at a node beneath a * We were trying to find glue at a node beneath a
* zone cut, but didn't, so we return the delegation. * zone cut, but didn't, so we return the delegation.
*/ */
result = setup_delegation(&search, nodep, foundname, UNLOCK(&(search.rbtdb->node_locks[node->locknum].lock));
rdataset); result = setup_delegation(&search, nodep, foundname,
rdataset);
goto tree_exit;
} else { } else {
/* /*
* The desired type doesn't exist. * The desired type doesn't exist.
*/ */
result = DNS_R_NXRDATASET; result = DNS_R_NXRDATASET;
if (secure_zone && nxtheader == NULL) { if (secure_zone && nxtheader == NULL) {
/* /*
* The zone is secure but there's no NXT * The zone is secure but there's no NXT
@@ -1383,6 +1400,10 @@ cache_zonecut_callback(dns_rbtnode_t *node, dns_name_t *name, void *arg) {
} }
if (header != NULL) { if (header != NULL) {
/*
* We increment the reference count on node to ensure that
* search->zonecut_rdataset will still be valid later.
*/
new_reference(search->rbtdb, node); new_reference(search->rbtdb, node);
search->zonecut = node; search->zonecut = node;
search->zonecut_rdataset = header; search->zonecut_rdataset = header;
@@ -1525,10 +1546,8 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version,
if (result == DNS_R_PARTIALMATCH) { if (result == DNS_R_PARTIALMATCH) {
if (search.zonecut != NULL) { if (search.zonecut != NULL) {
LOCK(&(search.rbtdb->node_locks[node->locknum].lock));
result = setup_delegation(&search, nodep, foundname, result = setup_delegation(&search, nodep, foundname,
rdataset); rdataset);
UNLOCK(&(search.rbtdb->node_locks[node->locknum].lock));
goto tree_exit; goto tree_exit;
} else { } else {
find_ns: find_ns: