mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
Silence missing unlock from Coverity.
Save 'i' to 'locknum' and use that rather than using 'header->node->locknum' when performing the deferred unlock as 'header->node->locknum' can theoretically be different to 'i'.
This commit is contained in:
@@ -8075,7 +8075,7 @@ getsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, dns_name_t *foundname) {
|
|||||||
rdatasetheader_t *header = NULL, *this;
|
rdatasetheader_t *header = NULL, *this;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
isc_result_t result = ISC_R_NOTFOUND;
|
isc_result_t result = ISC_R_NOTFOUND;
|
||||||
unsigned int locknum;
|
unsigned int locknum = 0;
|
||||||
|
|
||||||
REQUIRE(VALID_RBTDB(rbtdb));
|
REQUIRE(VALID_RBTDB(rbtdb));
|
||||||
|
|
||||||
@@ -8083,41 +8083,64 @@ getsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, dns_name_t *foundname) {
|
|||||||
|
|
||||||
for (i = 0; i < rbtdb->node_lock_count; i++) {
|
for (i = 0; i < rbtdb->node_lock_count; i++) {
|
||||||
NODE_LOCK(&rbtdb->node_locks[i].lock, isc_rwlocktype_read);
|
NODE_LOCK(&rbtdb->node_locks[i].lock, isc_rwlocktype_read);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Find for the earliest signing time among all of the
|
||||||
|
* heaps, each of which is covered by a different bucket
|
||||||
|
* lock.
|
||||||
|
*/
|
||||||
this = isc_heap_element(rbtdb->heaps[i], 1);
|
this = isc_heap_element(rbtdb->heaps[i], 1);
|
||||||
if (this == NULL) {
|
if (this == NULL) {
|
||||||
|
/* Nothing found; unlock and try the next heap. */
|
||||||
NODE_UNLOCK(&rbtdb->node_locks[i].lock,
|
NODE_UNLOCK(&rbtdb->node_locks[i].lock,
|
||||||
isc_rwlocktype_read);
|
isc_rwlocktype_read);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header == NULL) {
|
if (header == NULL) {
|
||||||
|
/*
|
||||||
|
* Found a signing time: retain the bucket lock and
|
||||||
|
* preserve the lock number so we can unlock it
|
||||||
|
* later.
|
||||||
|
*/
|
||||||
header = this;
|
header = this;
|
||||||
|
locknum = i;
|
||||||
} else if (resign_sooner(this, header)) {
|
} else if (resign_sooner(this, header)) {
|
||||||
locknum = header->node->locknum;
|
/*
|
||||||
|
* Found an earlier signing time; release the
|
||||||
|
* previous bucket lock and retain this one instead.
|
||||||
|
*/
|
||||||
NODE_UNLOCK(&rbtdb->node_locks[locknum].lock,
|
NODE_UNLOCK(&rbtdb->node_locks[locknum].lock,
|
||||||
isc_rwlocktype_read);
|
isc_rwlocktype_read);
|
||||||
header = this;
|
header = this;
|
||||||
|
locknum = i;
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* Earliest signing time in this heap isn't
|
||||||
|
* an improvement; unlock and try the next heap.
|
||||||
|
*/
|
||||||
NODE_UNLOCK(&rbtdb->node_locks[i].lock,
|
NODE_UNLOCK(&rbtdb->node_locks[i].lock,
|
||||||
isc_rwlocktype_read);
|
isc_rwlocktype_read);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header == NULL) {
|
if (header != NULL) {
|
||||||
goto unlock;
|
/*
|
||||||
|
* Found something; pass back the answer and unlock
|
||||||
|
* the bucket.
|
||||||
|
*/
|
||||||
|
bind_rdataset(rbtdb, header->node, header, 0, rdataset);
|
||||||
|
|
||||||
|
if (foundname != NULL) {
|
||||||
|
dns_rbt_fullnamefromnode(header->node, foundname);
|
||||||
|
}
|
||||||
|
|
||||||
|
NODE_UNLOCK(&rbtdb->node_locks[locknum].lock,
|
||||||
|
isc_rwlocktype_read);
|
||||||
|
|
||||||
|
result = ISC_R_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bind_rdataset(rbtdb, header->node, header, 0, rdataset);
|
|
||||||
|
|
||||||
if (foundname != NULL) {
|
|
||||||
dns_rbt_fullnamefromnode(header->node, foundname);
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_UNLOCK(&rbtdb->node_locks[header->node->locknum].lock,
|
|
||||||
isc_rwlocktype_read);
|
|
||||||
|
|
||||||
result = ISC_R_SUCCESS;
|
|
||||||
|
|
||||||
unlock:
|
|
||||||
RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
|
RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
|
Reference in New Issue
Block a user