mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
Merge branch '1697-isc_rwlock_init-can-no-longer-fail-in-master-clean-up-calls' into 'main'
Resolve "isc_rwlock_init can no longer fail in master, clean up calls." Closes #2462 and #1697 See merge request isc-projects/bind9!4635
This commit is contained in:
commit
6b79a0ce9d
@ -3806,11 +3806,7 @@ main(int argc, char *argv[]) {
|
||||
* of keys rather early.
|
||||
*/
|
||||
ISC_LIST_INIT(keylist);
|
||||
result = isc_rwlock_init(&keylist_lock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("could not initialize keylist_lock: %s",
|
||||
isc_result_totext(result));
|
||||
}
|
||||
isc_rwlock_init(&keylist_lock, 0, 0);
|
||||
|
||||
/*
|
||||
* Fill keylist with:
|
||||
|
@ -66,7 +66,7 @@ static dns_dbimplementation_t rbtimp;
|
||||
|
||||
static void
|
||||
initialize(void) {
|
||||
RUNTIME_CHECK(isc_rwlock_init(&implock, 0, 0) == ISC_R_SUCCESS);
|
||||
isc_rwlock_init(&implock, 0, 0);
|
||||
|
||||
rbtimp.name = "rbt";
|
||||
rbtimp.create = dns_rbtdb_create;
|
||||
|
@ -79,7 +79,7 @@ static isc_once_t once = ISC_ONCE_INIT;
|
||||
|
||||
static void
|
||||
dlz_initialize(void) {
|
||||
RUNTIME_CHECK(isc_rwlock_init(&dlz_implock, 0, 0) == ISC_R_SUCCESS);
|
||||
isc_rwlock_init(&dlz_implock, 0, 0);
|
||||
ISC_LIST_INIT(dlz_implementations);
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,7 @@ dns_fwdtable_create(isc_mem_t *mctx, dns_fwdtable_t **fwdtablep) {
|
||||
goto cleanup_fwdtable;
|
||||
}
|
||||
|
||||
result = isc_rwlock_init(&fwdtable->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rbt;
|
||||
}
|
||||
|
||||
isc_rwlock_init(&fwdtable->rwlock, 0, 0);
|
||||
fwdtable->mctx = NULL;
|
||||
isc_mem_attach(mctx, &fwdtable->mctx);
|
||||
fwdtable->magic = FWDTABLEMAGIC;
|
||||
@ -63,9 +59,6 @@ dns_fwdtable_create(isc_mem_t *mctx, dns_fwdtable_t **fwdtablep) {
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_rbt:
|
||||
dns_rbt_destroy(&fwdtable->table);
|
||||
|
||||
cleanup_fwdtable:
|
||||
isc_mem_put(mctx, fwdtable, sizeof(dns_fwdtable_t));
|
||||
|
||||
|
@ -156,11 +156,7 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
|
||||
goto cleanup_keytable;
|
||||
}
|
||||
|
||||
result = isc_rwlock_init(&keytable->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rbt;
|
||||
}
|
||||
|
||||
isc_rwlock_init(&keytable->rwlock, 0, 0);
|
||||
isc_refcount_init(&keytable->references, 1);
|
||||
|
||||
keytable->mctx = NULL;
|
||||
@ -170,9 +166,6 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_rbt:
|
||||
dns_rbt_destroy(&keytable->table);
|
||||
|
||||
cleanup_keytable:
|
||||
isc_mem_putanddetach(&mctx, keytable, sizeof(*keytable));
|
||||
|
||||
@ -338,7 +331,6 @@ static dns_keynode_t *
|
||||
new_keynode(dns_rdata_ds_t *ds, dns_keytable_t *keytable, bool managed,
|
||||
bool initial) {
|
||||
dns_keynode_t *knode = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(VALID_KEYTABLE(keytable));
|
||||
REQUIRE(!initial || managed);
|
||||
@ -348,8 +340,7 @@ new_keynode(dns_rdata_ds_t *ds, dns_keytable_t *keytable, bool managed,
|
||||
|
||||
dns_rdataset_init(&knode->dsset);
|
||||
isc_refcount_init(&knode->refcount, 1);
|
||||
result = isc_rwlock_init(&knode->rwlock, 0, 0);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
isc_rwlock_init(&knode->rwlock, 0, 0);
|
||||
|
||||
/*
|
||||
* If a DS was supplied, initialize an rdatalist.
|
||||
|
@ -123,10 +123,7 @@ dns_ntatable_create(dns_view_t *view, isc_taskmgr_t *taskmgr,
|
||||
goto cleanup_task;
|
||||
}
|
||||
|
||||
result = isc_rwlock_init(&ntatable->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rbt;
|
||||
}
|
||||
isc_rwlock_init(&ntatable->rwlock, 0, 0);
|
||||
|
||||
ntatable->shuttingdown = false;
|
||||
ntatable->timermgr = timermgr;
|
||||
@ -140,9 +137,6 @@ dns_ntatable_create(dns_view_t *view, isc_taskmgr_t *taskmgr,
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_rbt:
|
||||
dns_rbt_destroy(&ntatable->table);
|
||||
|
||||
cleanup_task:
|
||||
isc_task_detach(&ntatable->task);
|
||||
|
||||
|
125
lib/dns/rbtdb.c
125
lib/dns/rbtdb.c
@ -1319,7 +1319,6 @@ currentversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
||||
static inline rbtdb_version_t *
|
||||
allocate_version(isc_mem_t *mctx, rbtdb_serial_t serial,
|
||||
unsigned int references, bool writer) {
|
||||
isc_result_t result;
|
||||
rbtdb_version_t *version;
|
||||
size_t size;
|
||||
|
||||
@ -1327,13 +1326,7 @@ allocate_version(isc_mem_t *mctx, rbtdb_serial_t serial,
|
||||
version->serial = serial;
|
||||
|
||||
isc_refcount_init(&version->references, references);
|
||||
|
||||
result = isc_rwlock_init(&version->glue_rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_refcount_destroy(&version->references);
|
||||
isc_mem_put(mctx, version, sizeof(*version));
|
||||
return (NULL);
|
||||
}
|
||||
isc_rwlock_init(&version->glue_rwlock, 0, 0);
|
||||
|
||||
version->glue_table_bits = RBTDB_GLUE_TABLE_INIT_BITS;
|
||||
version->glue_table_nodecount = 0U;
|
||||
@ -1354,7 +1347,7 @@ allocate_version(isc_mem_t *mctx, rbtdb_serial_t serial,
|
||||
|
||||
static isc_result_t
|
||||
newversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
||||
isc_result_t result;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db;
|
||||
rbtdb_version_t *version;
|
||||
|
||||
@ -1366,48 +1359,31 @@ newversion(dns_db_t *db, dns_dbversion_t **versionp) {
|
||||
RUNTIME_CHECK(rbtdb->next_serial != 0); /* XXX Error? */
|
||||
version = allocate_version(rbtdb->common.mctx, rbtdb->next_serial, 1,
|
||||
true);
|
||||
if (version != NULL) {
|
||||
version->rbtdb = rbtdb;
|
||||
version->commit_ok = true;
|
||||
version->secure = rbtdb->current_version->secure;
|
||||
version->havensec3 = rbtdb->current_version->havensec3;
|
||||
if (version->havensec3) {
|
||||
version->flags = rbtdb->current_version->flags;
|
||||
version->iterations =
|
||||
rbtdb->current_version->iterations;
|
||||
version->hash = rbtdb->current_version->hash;
|
||||
version->salt_length =
|
||||
rbtdb->current_version->salt_length;
|
||||
memmove(version->salt, rbtdb->current_version->salt,
|
||||
version->salt_length);
|
||||
} else {
|
||||
version->flags = 0;
|
||||
version->iterations = 0;
|
||||
version->hash = 0;
|
||||
version->salt_length = 0;
|
||||
memset(version->salt, 0, sizeof(version->salt));
|
||||
}
|
||||
result = isc_rwlock_init(&version->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
free_gluetable(version);
|
||||
isc_rwlock_destroy(&version->glue_rwlock);
|
||||
isc_refcount_destroy(&version->references);
|
||||
isc_mem_put(rbtdb->common.mctx, version,
|
||||
sizeof(*version));
|
||||
version = NULL;
|
||||
} else {
|
||||
RWLOCK(&rbtdb->current_version->rwlock,
|
||||
isc_rwlocktype_read);
|
||||
version->records = rbtdb->current_version->records;
|
||||
version->xfrsize = rbtdb->current_version->xfrsize;
|
||||
RWUNLOCK(&rbtdb->current_version->rwlock,
|
||||
isc_rwlocktype_read);
|
||||
rbtdb->next_serial++;
|
||||
rbtdb->future_version = version;
|
||||
}
|
||||
version->rbtdb = rbtdb;
|
||||
version->commit_ok = true;
|
||||
version->secure = rbtdb->current_version->secure;
|
||||
version->havensec3 = rbtdb->current_version->havensec3;
|
||||
if (version->havensec3) {
|
||||
version->flags = rbtdb->current_version->flags;
|
||||
version->iterations = rbtdb->current_version->iterations;
|
||||
version->hash = rbtdb->current_version->hash;
|
||||
version->salt_length = rbtdb->current_version->salt_length;
|
||||
memmove(version->salt, rbtdb->current_version->salt,
|
||||
version->salt_length);
|
||||
} else {
|
||||
result = ISC_R_NOMEMORY;
|
||||
version->flags = 0;
|
||||
version->iterations = 0;
|
||||
version->hash = 0;
|
||||
version->salt_length = 0;
|
||||
memset(version->salt, 0, sizeof(version->salt));
|
||||
}
|
||||
isc_rwlock_init(&version->rwlock, 0, 0);
|
||||
RWLOCK(&rbtdb->current_version->rwlock, isc_rwlocktype_read);
|
||||
version->records = rbtdb->current_version->records;
|
||||
version->xfrsize = rbtdb->current_version->xfrsize;
|
||||
RWUNLOCK(&rbtdb->current_version->rwlock, isc_rwlocktype_read);
|
||||
rbtdb->next_serial++;
|
||||
rbtdb->future_version = version;
|
||||
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
|
||||
|
||||
if (version == NULL) {
|
||||
@ -8598,15 +8574,9 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
|
||||
ISC_LIST_INIT(rbtdb->common.update_listeners);
|
||||
|
||||
result = RBTDB_INITLOCK(&rbtdb->lock);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rbtdb;
|
||||
}
|
||||
RBTDB_INITLOCK(&rbtdb->lock);
|
||||
|
||||
result = isc_rwlock_init(&rbtdb->tree_lock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_lock;
|
||||
}
|
||||
isc_rwlock_init(&rbtdb->tree_lock, 0, 0);
|
||||
|
||||
/*
|
||||
* Initialize node_lock_count in a generic way to support future
|
||||
@ -8676,18 +8646,8 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
rbtdb->active = rbtdb->node_lock_count;
|
||||
|
||||
for (i = 0; i < (int)(rbtdb->node_lock_count); i++) {
|
||||
result = NODE_INITLOCK(&rbtdb->node_locks[i].lock);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_refcount_init(&rbtdb->node_locks[i].references, 0);
|
||||
}
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
while (i-- > 0) {
|
||||
NODE_DESTROYLOCK(&rbtdb->node_locks[i].lock);
|
||||
isc_refcount_destroy(
|
||||
&rbtdb->node_locks[i].references);
|
||||
}
|
||||
goto cleanup_deadnodes;
|
||||
}
|
||||
NODE_INITLOCK(&rbtdb->node_locks[i].lock);
|
||||
isc_refcount_init(&rbtdb->node_locks[i].references, 0);
|
||||
rbtdb->node_locks[i].exiting = false;
|
||||
}
|
||||
|
||||
@ -8799,11 +8759,6 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
rbtdb->least_serial = 1;
|
||||
rbtdb->next_serial = 2;
|
||||
rbtdb->current_version = allocate_version(mctx, 1, 1, false);
|
||||
if (rbtdb->current_version == NULL) {
|
||||
isc_refcount_decrementz(&rbtdb->references);
|
||||
free_rbtdb(rbtdb, false, NULL);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
rbtdb->current_version->rbtdb = rbtdb;
|
||||
rbtdb->current_version->secure = dns_db_insecure;
|
||||
rbtdb->current_version->havensec3 = false;
|
||||
@ -8813,19 +8768,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
rbtdb->current_version->salt_length = 0;
|
||||
memset(rbtdb->current_version->salt, 0,
|
||||
sizeof(rbtdb->current_version->salt));
|
||||
result = isc_rwlock_init(&rbtdb->current_version->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
free_gluetable(rbtdb->current_version);
|
||||
isc_rwlock_destroy(&rbtdb->current_version->glue_rwlock);
|
||||
isc_refcount_destroy(&rbtdb->current_version->references);
|
||||
isc_mem_put(mctx, rbtdb->current_version,
|
||||
sizeof(*rbtdb->current_version));
|
||||
rbtdb->current_version = NULL;
|
||||
isc_refcount_decrementz(&rbtdb->references);
|
||||
free_rbtdb(rbtdb, false, NULL);
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_rwlock_init(&rbtdb->current_version->rwlock, 0, 0);
|
||||
rbtdb->current_version->records = 0;
|
||||
rbtdb->current_version->xfrsize = 0;
|
||||
rbtdb->future_version = NULL;
|
||||
@ -8843,10 +8786,6 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_deadnodes:
|
||||
isc_mem_put(mctx, rbtdb->deadnodes,
|
||||
rbtdb->node_lock_count * sizeof(rbtnodelist_t));
|
||||
|
||||
cleanup_heaps:
|
||||
if (rbtdb->heaps != NULL) {
|
||||
for (i = 0; i < (int)rbtdb->node_lock_count; i++) {
|
||||
@ -8873,11 +8812,7 @@ cleanup_node_locks:
|
||||
|
||||
cleanup_tree_lock:
|
||||
isc_rwlock_destroy(&rbtdb->tree_lock);
|
||||
|
||||
cleanup_lock:
|
||||
RBTDB_DESTROYLOCK(&rbtdb->lock);
|
||||
|
||||
cleanup_rbtdb:
|
||||
isc_mem_put(mctx, rbtdb, sizeof(*rbtdb));
|
||||
return (result);
|
||||
}
|
||||
|
@ -10473,23 +10473,10 @@ dns_resolver_create(dns_view_t *view, isc_taskmgr_t *taskmgr,
|
||||
}
|
||||
|
||||
#if USE_ALGLOCK
|
||||
result = isc_rwlock_init(&res->alglock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_spillattimer;
|
||||
}
|
||||
isc_rwlock_init(&res->alglock, 0, 0);
|
||||
#endif /* if USE_ALGLOCK */
|
||||
#if USE_MBSLOCK
|
||||
result = isc_rwlock_init(&res->mbslock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
#if USE_ALGLOCK
|
||||
{
|
||||
goto cleanup_alglock;
|
||||
}
|
||||
#else /* if USE_ALGLOCK */
|
||||
{
|
||||
goto cleanup_spillattimer;
|
||||
}
|
||||
#endif /* if USE_ALGLOCK */
|
||||
isc_rwlock_init(&res->mbslock, 0, 0);
|
||||
#endif /* if USE_MBSLOCK */
|
||||
|
||||
res->magic = RES_MAGIC;
|
||||
@ -10498,16 +10485,6 @@ dns_resolver_create(dns_view_t *view, isc_taskmgr_t *taskmgr,
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
#if USE_ALGLOCK && USE_MBSLOCK
|
||||
cleanup_alglock:
|
||||
isc_rwlock_destroy(&res->alglock);
|
||||
#endif /* if USE_ALGLOCK && USE_MBSLOCK */
|
||||
|
||||
#if USE_ALGLOCK || USE_MBSLOCK
|
||||
cleanup_spillattimer:
|
||||
isc_timer_detach(&res->spillattimer);
|
||||
#endif /* if USE_ALGLOCK || USE_MBSLOCK */
|
||||
|
||||
cleanup_primelock:
|
||||
isc_mutex_destroy(&res->primelock);
|
||||
isc_mutex_destroy(&res->lock);
|
||||
|
@ -1452,18 +1452,14 @@ dns_rpz_new_zones(dns_rpz_zones_t **rpzsp, char *rps_cstr, size_t rps_cstr_size,
|
||||
isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
||||
isc_timermgr_t *timermgr) {
|
||||
dns_rpz_zones_t *zones;
|
||||
isc_result_t result;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
REQUIRE(rpzsp != NULL && *rpzsp == NULL);
|
||||
|
||||
zones = isc_mem_get(mctx, sizeof(*zones));
|
||||
memset(zones, 0, sizeof(*zones));
|
||||
|
||||
result = isc_rwlock_init(&zones->search_lock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rwlock;
|
||||
}
|
||||
|
||||
isc_rwlock_init(&zones->search_lock, 0, 0);
|
||||
isc_mutex_init(&zones->maint_lock);
|
||||
isc_refcount_init(&zones->refs, 1);
|
||||
isc_refcount_init(&zones->irefs, 1);
|
||||
@ -1506,12 +1502,8 @@ cleanup_rbt:
|
||||
isc_refcount_destroy(&zones->irefs);
|
||||
isc_refcount_decrementz(&zones->refs);
|
||||
isc_refcount_destroy(&zones->refs);
|
||||
|
||||
isc_mutex_destroy(&zones->maint_lock);
|
||||
|
||||
isc_rwlock_destroy(&zones->search_lock);
|
||||
|
||||
cleanup_rwlock:
|
||||
isc_mem_put(mctx, zones, sizeof(*zones));
|
||||
|
||||
return (result);
|
||||
|
@ -1830,12 +1830,7 @@ dns_tsigkeyring_create(isc_mem_t *mctx, dns_tsig_keyring_t **ringp) {
|
||||
|
||||
ring = isc_mem_get(mctx, sizeof(dns_tsig_keyring_t));
|
||||
|
||||
result = isc_rwlock_init(&ring->lock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(mctx, ring, sizeof(dns_tsig_keyring_t));
|
||||
return (result);
|
||||
}
|
||||
|
||||
isc_rwlock_init(&ring->lock, 0, 0);
|
||||
ring->keys = NULL;
|
||||
result = dns_rbt_create(mctx, free_tsignode, NULL, &ring->keys);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
@ -989,14 +989,8 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||
|
||||
zone->mctx = NULL;
|
||||
isc_mem_attach(mctx, &zone->mctx);
|
||||
|
||||
isc_mutex_init(&zone->lock);
|
||||
|
||||
result = ZONEDB_INITLOCK(&zone->dblock);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto free_mutex;
|
||||
}
|
||||
|
||||
ZONEDB_INITLOCK(&zone->dblock);
|
||||
/* XXX MPA check that all elements are initialised */
|
||||
#ifdef DNS_ZONE_CHECKLOCK
|
||||
zone->locked = false;
|
||||
@ -1176,12 +1170,8 @@ free_refs:
|
||||
isc_refcount_decrement0(&zone->erefs);
|
||||
isc_refcount_destroy(&zone->erefs);
|
||||
isc_refcount_destroy(&zone->irefs);
|
||||
|
||||
ZONEDB_DESTROYLOCK(&zone->dblock);
|
||||
|
||||
free_mutex:
|
||||
isc_mutex_destroy(&zone->lock);
|
||||
|
||||
isc_mem_putanddetach(&zone->mctx, zone, sizeof(*zone));
|
||||
return (result);
|
||||
}
|
||||
@ -18067,19 +18057,13 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
|
||||
ISC_LIST_INIT(zmgr->waiting_for_xfrin);
|
||||
ISC_LIST_INIT(zmgr->xfrin_in_progress);
|
||||
memset(zmgr->unreachable, 0, sizeof(zmgr->unreachable));
|
||||
result = isc_rwlock_init(&zmgr->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto free_mem;
|
||||
}
|
||||
isc_rwlock_init(&zmgr->rwlock, 0, 0);
|
||||
|
||||
zmgr->transfersin = 10;
|
||||
zmgr->transfersperns = 2;
|
||||
|
||||
/* Unreachable lock. */
|
||||
result = isc_rwlock_init(&zmgr->urlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto free_rwlock;
|
||||
}
|
||||
isc_rwlock_init(&zmgr->urlock, 0, 0);
|
||||
|
||||
/* Create a single task for queueing of SOA queries. */
|
||||
result = isc_task_create(taskmgr, 1, &zmgr->task);
|
||||
@ -18146,9 +18130,7 @@ free_task:
|
||||
isc_task_detach(&zmgr->task);
|
||||
free_urlock:
|
||||
isc_rwlock_destroy(&zmgr->urlock);
|
||||
free_rwlock:
|
||||
isc_rwlock_destroy(&zmgr->rwlock);
|
||||
free_mem:
|
||||
isc_mem_put(zmgr->mctx, zmgr, sizeof(*zmgr));
|
||||
isc_mem_detach(&mctx);
|
||||
return (result);
|
||||
|
@ -88,11 +88,7 @@ dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) {
|
||||
goto cleanup_zt;
|
||||
}
|
||||
|
||||
result = isc_rwlock_init(&zt->rwlock, 0, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rbt;
|
||||
}
|
||||
|
||||
isc_rwlock_init(&zt->rwlock, 0, 0);
|
||||
zt->mctx = NULL;
|
||||
isc_mem_attach(mctx, &zt->mctx);
|
||||
isc_refcount_init(&zt->references, 1);
|
||||
@ -107,9 +103,6 @@ dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) {
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_rbt:
|
||||
dns_rbt_destroy(&zt->table);
|
||||
|
||||
cleanup_zt:
|
||||
isc_mem_put(mctx, zt, sizeof(*zt));
|
||||
|
||||
|
@ -78,7 +78,7 @@ struct isc_rwlock {
|
||||
|
||||
#endif /* USE_PTHREAD_RWLOCK */
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
|
||||
unsigned int write_quota);
|
||||
|
||||
|
@ -31,14 +31,13 @@
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
|
||||
unsigned int write_quota) {
|
||||
UNUSED(read_quota);
|
||||
UNUSED(write_quota);
|
||||
REQUIRE(pthread_rwlock_init(&rwl->rwlock, NULL) == 0);
|
||||
atomic_init(&rwl->downgrade, false);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@ -189,7 +188,7 @@ print_lock(const char *operation, isc_rwlock_t *rwl, isc_rwlocktype_t type) {
|
||||
}
|
||||
#endif /* ISC_RWLOCK_TRACE */
|
||||
|
||||
isc_result_t
|
||||
void
|
||||
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
|
||||
unsigned int write_quota) {
|
||||
REQUIRE(rwl != NULL);
|
||||
@ -221,8 +220,6 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
|
||||
isc_condition_init(&rwl->writeable);
|
||||
|
||||
rwl->magic = RWLOCK_MAGIC;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user