static void
overmem_purge(dns_rbtdb_t *rbtdb, unsigned int locknum_start, isc_stdtime_t now,
bool tree_locked);
-static isc_result_t
+static void
resign_insert(dns_rbtdb_t *rbtdb, int idx, rdatasetheader_t *newheader);
static void
resign_delete(dns_rbtdb_t *rbtdb, rbtdb_version_t *version,
lock = &rbtdb->node_locks[header->node->locknum].lock;
NODE_LOCK(lock, isc_rwlocktype_write);
if (rollback && !IGNORE(header)) {
- isc_result_t result;
- result = resign_insert(rbtdb, header->node->locknum,
- header);
- if (result != ISC_R_SUCCESS) {
- isc_log_write(dns_lctx,
- DNS_LOGCATEGORY_DATABASE,
- DNS_LOGMODULE_ZONE, ISC_LOG_ERROR,
- "Unable to reinsert header to "
- "re-signing heap: %s",
- dns_result_totext(result));
- }
+ resign_insert(rbtdb, header->node->locknum, header);
}
decrement_reference(rbtdb, header->node, least_serial,
isc_rwlocktype_write, isc_rwlocktype_none,
return (false);
}
-static isc_result_t
+static void
resign_insert(dns_rbtdb_t *rbtdb, int idx, rdatasetheader_t *newheader) {
- isc_result_t result;
-
INSIST(!IS_CACHE(rbtdb));
INSIST(newheader->heap_index == 0);
INSIST(!ISC_LINK_LINKED(newheader, link));
- result = isc_heap_insert(rbtdb->heaps[idx], newheader);
- return (result);
+ isc_heap_insert(rbtdb->heaps[idx], newheader);
}
/*
newheader, link);
}
INSIST(rbtdb->heaps != NULL);
- result = isc_heap_insert(rbtdb->heaps[idx],
- newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- return (result);
- }
+ isc_heap_insert(rbtdb->heaps[idx], newheader);
} else if (RESIGN(newheader)) {
- result = resign_insert(rbtdb, idx, newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- return (result);
- }
+ resign_insert(rbtdb, idx, newheader);
/*
* Don't call resign_delete as we don't need
* to reverse the delete. The free_rdataset
idx = newheader->node->locknum;
if (IS_CACHE(rbtdb)) {
INSIST(rbtdb->heaps != NULL);
- result = isc_heap_insert(rbtdb->heaps[idx],
- newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- return (result);
- }
+ isc_heap_insert(rbtdb->heaps[idx], newheader);
if (ZEROTTL(newheader)) {
ISC_LIST_APPEND(rbtdb->rdatasets[idx],
newheader, link);
newheader, link);
}
} else if (RESIGN(newheader)) {
- result = resign_insert(rbtdb, idx, newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- return (result);
- }
+ resign_insert(rbtdb, idx, newheader);
resign_delete(rbtdb, rbtversion, header);
}
if (topheader_prev != NULL) {
idx = newheader->node->locknum;
if (IS_CACHE(rbtdb)) {
- result = isc_heap_insert(rbtdb->heaps[idx], newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- return (result);
- }
+ isc_heap_insert(rbtdb->heaps[idx], newheader);
if (ZEROTTL(newheader)) {
ISC_LIST_APPEND(rbtdb->rdatasets[idx],
newheader, link);
newheader, link);
}
} else if (RESIGN(newheader)) {
- result = resign_insert(rbtdb, idx, newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- return (result);
- }
+ resign_insert(rbtdb, idx, newheader);
resign_delete(rbtdb, rbtversion, header);
}
RDATASET_ATTR_RESIGN);
newheader->resign = header->resign;
newheader->resign_lsb = header->resign_lsb;
- result = resign_insert(rbtdb, rbtnode->locknum,
- newheader);
- if (result != ISC_R_SUCCESS) {
- free_rdataset(rbtdb, rbtdb->common.mctx,
- newheader);
- goto unlock;
- }
+ resign_insert(rbtdb, rbtnode->locknum,
+ newheader);
}
/*
* We have to set the serial since the rdataslab
static isc_result_t
rbt_datafixer(dns_rbtnode_t *rbtnode, void *base, size_t filesize, void *arg,
uint64_t *crc) {
- isc_result_t result;
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)arg;
rdatasetheader_t *header;
unsigned char *limit = ((unsigned char *)base) + filesize;
if (RESIGN(header) &&
(header->resign != 0 || header->resign_lsb != 0)) {
int idx = header->node->locknum;
- result = isc_heap_insert(rbtdb->heaps[idx], header);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ isc_heap_insert(rbtdb->heaps[idx], header);
}
if (header->next != NULL) {
static isc_result_t
setsigningtime(dns_db_t *db, dns_rdataset_t *rdataset, isc_stdtime_t resign) {
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
- isc_result_t result = ISC_R_SUCCESS;
rdatasetheader_t *header, oldheader;
REQUIRE(VALID_RBTDB(rbtdb));
}
} else if (resign != 0) {
RDATASET_ATTR_SET(header, RDATASET_ATTR_RESIGN);
- result = resign_insert(rbtdb, header->node->locknum, header);
+ resign_insert(rbtdb, header->node->locknum, header);
}
NODE_UNLOCK(&rbtdb->node_locks[header->node->locknum].lock,
isc_rwlocktype_write);
- return (result);
+ return (ISC_R_SUCCESS);
}
static isc_result_t
}
sooner = IS_CACHE(rbtdb) ? ttl_sooner : resign_sooner;
for (i = 0; i < (int)rbtdb->node_lock_count; i++) {
- result = isc_heap_create(hmctx, sooner, set_index, 0,
- &rbtdb->heaps[i]);
- if (result != ISC_R_SUCCESS) {
- goto cleanup_heaps;
- }
+ isc_heap_create(hmctx, sooner, set_index, 0, &rbtdb->heaps[i]);
}
/*
return (ISC_R_SUCCESS);
-cleanup_heaps:
- if (rbtdb->heaps != NULL) {
- for (i = 0; i < (int)rbtdb->node_lock_count; i++) {
- if (rbtdb->heaps[i] != NULL) {
- isc_heap_destroy(&rbtdb->heaps[i]);
- }
- }
- isc_mem_put(hmctx, rbtdb->heaps,
- rbtdb->node_lock_count * sizeof(isc_heap_t *));
- }
-
- if (rbtdb->rdatasets != NULL) {
- isc_mem_put(mctx, rbtdb->rdatasets,
- rbtdb->node_lock_count *
- sizeof(rdatasetheaderlist_t));
- }
- if (rbtdb->rrsetstats != NULL) {
- dns_stats_detach(&rbtdb->rrsetstats);
- }
-
cleanup_node_locks:
isc_mem_put(mctx, rbtdb->node_locks,
rbtdb->node_lock_count * sizeof(rbtdb_nodelock_t));
return (memcmp(e1 + 1, e2 + 1, data_length) == 0);
}
-static isc_result_t
+static void
record_nsec3(const vctx_t *vctx, const unsigned char *rawhash,
const dns_rdata_nsec3_t *nsec3, isc_heap_t *chains) {
- struct nsec3_chain_fixed *element;
+ struct nsec3_chain_fixed *element = NULL;
+ unsigned char *cp = NULL;
size_t len;
- unsigned char *cp;
- isc_result_t result;
len = sizeof(*element) + nsec3->next_length * 2 + nsec3->salt_length;
memmove(cp, rawhash, nsec3->next_length);
cp += nsec3->next_length;
memmove(cp, nsec3->next, nsec3->next_length);
- result = isc_heap_insert(chains, element);
- if (result != ISC_R_SUCCESS) {
- zoneverify_log_error(vctx, "isc_heap_insert failed: %s",
- isc_result_totext(result));
- isc_mem_put(vctx->mctx, element, len);
- }
- return (result);
+ isc_heap_insert(chains, element);
}
/*
/*
* Record chain.
*/
- result = record_nsec3(vctx, rawhash, &nsec3, vctx->expected_chains);
- if (result != ISC_R_SUCCESS) {
- zoneverify_log_error(vctx, "record_nsec3(): %s",
- isc_result_totext(result));
- return (result);
- }
+ record_nsec3(vctx, rawhash, &nsec3, vctx->expected_chains);
/*
* Make sure there is only one NSEC3 record with this set of
if (nsec3.next_length != isc_buffer_usedlength(&b)) {
continue;
}
+
/*
* We only care about NSEC3 records that match a NSEC3PARAM
* record.
/*
* Record chain.
*/
- result = record_nsec3(vctx, owner, &nsec3, vctx->found_chains);
- if (result != ISC_R_SUCCESS) {
- zoneverify_log_error(vctx, "record_nsec3(): %s",
- isc_result_totext(result));
- goto cleanup;
- }
+ record_nsec3(vctx, owner, &nsec3, vctx->found_chains);
}
result = ISC_R_SUCCESS;
return (ISC_R_SUCCESS);
}
-static isc_result_t
+static void
vctx_init(vctx_t *vctx, isc_mem_t *mctx, dns_zone_t *zone, dns_db_t *db,
dns_dbversion_t *ver, dns_name_t *origin, dns_keytable_t *secroots) {
- isc_result_t result;
-
memset(vctx, 0, sizeof(*vctx));
vctx->mctx = mctx;
dns_rdataset_init(&vctx->nsec3paramsigs);
vctx->expected_chains = NULL;
- result = isc_heap_create(mctx, chain_compare, NULL, 1024,
- &vctx->expected_chains);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ isc_heap_create(mctx, chain_compare, NULL, 1024,
+ &vctx->expected_chains);
vctx->found_chains = NULL;
- result = isc_heap_create(mctx, chain_compare, NULL, 1024,
- &vctx->found_chains);
- if (result != ISC_R_SUCCESS) {
- isc_heap_destroy(&vctx->expected_chains);
- return (result);
- }
-
- return (result);
+ isc_heap_create(mctx, chain_compare, NULL, 1024, &vctx->found_chains);
}
static void
isc_result_t result, vresult = ISC_R_UNSET;
vctx_t vctx;
- result = vctx_init(&vctx, mctx, zone, db, ver, origin, secroots);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ vctx_init(&vctx, mctx, zone, db, ver, origin, secroots);
result = check_apex_rrsets(&vctx);
if (result != ISC_R_SUCCESS) {
#define heap_check(x) (void)0
#endif /* ifdef ISC_HEAP_CHECK */
-isc_result_t
+void
isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare, isc_heapindex_t idx,
unsigned int size_increment, isc_heap_t **heapp) {
isc_heap_t *heap;
heap->index = idx;
*heapp = heap;
-
- return (ISC_R_SUCCESS);
}
void
isc_mem_putanddetach(&heap->mctx, heap, sizeof(*heap));
}
-static bool
+static void
resize(isc_heap_t *heap) {
void **new_array;
unsigned int new_size;
}
heap->size = new_size;
heap->array = new_array;
-
- return (true);
}
static void
heap_check(heap);
}
-isc_result_t
+void
isc_heap_insert(isc_heap_t *heap, void *elt) {
unsigned int new_last;
heap_check(heap);
new_last = heap->last + 1;
RUNTIME_CHECK(new_last > 0); /* overflow check */
- if (new_last >= heap->size && !resize(heap)) {
- return (ISC_R_NOMEMORY);
+ if (new_last >= heap->size) {
+ resize(heap);
}
heap->last = new_last;
float_up(heap, new_last, elt);
-
- return (ISC_R_SUCCESS);
}
void
typedef struct isc_heap isc_heap_t;
-isc_result_t
+void
isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare,
isc_heapindex_t index, unsigned int size_increment,
isc_heap_t **heapp);
* used, which is currently 1024, allowing space for an additional 1024
* heap elements to be inserted before adding more space.
*\li "heapp" is not NULL, and "*heap" is NULL.
- *
- * Returns:
- *\li ISC_R_SUCCESS - success
- *\li ISC_R_NOMEMORY - insufficient memory
*/
void
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
*/
-isc_result_t
+void
isc_heap_insert(isc_heap_t *heap, void *elt);
/*!<
* \brief Inserts a new element into a heap.
static void
isc_heap_delete_test(void **state) {
isc_heap_t *heap = NULL;
- isc_result_t result;
struct e e1 = { 100, 0 };
UNUSED(state);
- result = isc_heap_create(test_mctx, compare, idx, 0, &heap);
- assert_int_equal(result, ISC_R_SUCCESS);
+ isc_heap_create(test_mctx, compare, idx, 0, &heap);
assert_non_null(heap);
isc_heap_insert(heap, &e1);
- assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(e1.index, 1);
isc_heap_delete(heap, e1.index);
static inline isc_result_t
schedule(isc_timer_t *timer, isc_time_t *now, bool signal_ok) {
- isc_result_t result;
isc_timermgr_t *manager;
isc_time_t due;
int cmp;
* Compute the new due time.
*/
if (timer->type != isc_timertype_once) {
- result = isc_time_add(now, &timer->interval, &due);
+ isc_result_t result = isc_time_add(now, &timer->interval, &due);
if (result != ISC_R_SUCCESS) {
return (result);
}
}
} else {
timer->due = due;
- result = isc_heap_insert(manager->heap, timer);
- if (result != ISC_R_SUCCESS) {
- INSIST(result == ISC_R_NOMEMORY);
- return (ISC_R_NOMEMORY);
- }
+ isc_heap_insert(manager->heap, timer);
manager->nscheduled++;
}
isc_result_t
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
isc_timermgr_t *manager;
- isc_result_t result;
/*
* Create a timer manager.
manager->nscheduled = 0;
isc_time_settoepoch(&manager->due);
manager->heap = NULL;
- result = isc_heap_create(mctx, sooner, set_index, 0, &manager->heap);
- if (result != ISC_R_SUCCESS) {
- INSIST(result == ISC_R_NOMEMORY);
- isc_mem_put(mctx, manager, sizeof(*manager));
- return (ISC_R_NOMEMORY);
- }
+ isc_heap_create(mctx, sooner, set_index, 0, &manager->heap);
isc_mutex_init(&manager->lock);
isc_mem_attach(mctx, &manager->mctx);
isc_condition_init(&manager->wakeup);