RWUNLOCK(&version->glue_rwlock, isc_rwlocktype_write);
}
-static bool
+/*%
+ * Write lock (version->glue_rwlock) must be held.
+ */
+static void
rehash_gluetable(rbtdb_version_t *version) {
size_t oldsize, i;
rbtdb_glue_table_node_t **oldtable;
if (ISC_LIKELY(version->glue_table_nodecount <
(version->glue_table_size * 3U))) {
- return (false);
+ return;
}
oldsize = version->glue_table_size;
if (ISC_UNLIKELY(version->glue_table == NULL)) {
version->glue_table = oldtable;
version->glue_table_size = oldsize;
- return (false);
+ return;
}
for (i = 0; i < version->glue_table_size; i++) {
"resized glue table from %" PRIu64 " to "
"%" PRIu64,
(uint64_t)oldsize, (uint64_t)version->glue_table_size);
-
- return (true);
}
static isc_result_t
rbtdb_glue_t *ge;
rbtdb_glue_additionaldata_ctx_t ctx;
isc_result_t result;
+ uint64_t hash;
REQUIRE(rdataset->type == dns_rdatatype_ns);
REQUIRE(rbtdb == rbtversion->rbtdb);
* the node pointer is a fixed value that won't change for a DB
* version and can be compared directly.
*/
- idx = isc_hash_function(&node, sizeof(node), true) %
- rbtversion->glue_table_size;
+ hash = isc_hash_function(&node, sizeof(node), true);
restart:
/*
*/
RWLOCK(&rbtversion->glue_rwlock, isc_rwlocktype_read);
+ idx = hash % rbtversion->glue_table_size;
+
for (cur = rbtversion->glue_table[idx]; cur != NULL; cur = cur->next) {
if (cur->node == node) {
break;
RWLOCK(&rbtversion->glue_rwlock, isc_rwlocktype_write);
- if (ISC_UNLIKELY(rehash_gluetable(rbtversion))) {
- idx = isc_hash_function(&node, sizeof(node), true) %
- rbtversion->glue_table_size;
- }
+ rehash_gluetable(rbtversion);
+ idx = hash % rbtversion->glue_table_size;
(void)dns_rdataset_additionaldata(rdataset, glue_nsdname_cb, &ctx);