Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee8d78a475 | ||
|
|
7069e2af7a | ||
|
|
e7580ac0f1 |
+1
-1
@@ -115,7 +115,7 @@ stages:
|
||||
- test -w "${CCACHE_DIR}" && export PATH="/usr/lib/ccache:${PATH}"
|
||||
# - ./autogen.sh
|
||||
script:
|
||||
- ./configure --enable-developer --with-libtool --disable-static --with-atf=/usr $EXTRA_CONFIGURE
|
||||
- ./configure --enable-developer --with-libtool --disable-static --with-atf=/usr $EXTRA_CONFIGURE || cat config.log
|
||||
- make -j${PARALLEL_JOBS_BUILD:-1} -k all V=1
|
||||
artifacts:
|
||||
expire_in: '1 hour'
|
||||
|
||||
@@ -773,7 +773,7 @@ create_db(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
|
||||
CHECK(dns_name_dupwithoffsets(origin, mctx, &sampledb->common.origin));
|
||||
|
||||
CHECK(isc_refcount_init(&sampledb->refs, 1));
|
||||
isc_refcount_init(&sampledb->refs, 1);
|
||||
|
||||
/* Translate instance name to instance pointer. */
|
||||
sampledb->inst = driverarg;
|
||||
|
||||
+1
-5
@@ -50,11 +50,7 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
|
||||
|
||||
acl->name = NULL;
|
||||
|
||||
result = isc_refcount_init(&acl->refcount, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(mctx, acl, sizeof(*acl));
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&acl->refcount, 1);
|
||||
|
||||
result = dns_iptable_create(mctx, &acl->iptable);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
||||
+1
-4
@@ -568,9 +568,7 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_newzones;
|
||||
|
||||
result = isc_refcount_init(&new_zones->refs, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_mutex;
|
||||
isc_refcount_init(&new_zones->refs, 1);
|
||||
|
||||
result = isc_ht_init(&new_zones->zones, mctx, 4);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -592,7 +590,6 @@ dns_catz_new_zones(dns_catz_zones_t **catzsp, dns_catz_zonemodmethods_t *zmm,
|
||||
isc_ht_destroy(&new_zones->zones);
|
||||
cleanup_refcount:
|
||||
isc_refcount_destroy(&new_zones->refs);
|
||||
cleanup_mutex:
|
||||
isc_mutex_destroy(&new_zones->lock);
|
||||
cleanup_newzones:
|
||||
isc_mem_put(mctx, new_zones, sizeof(*new_zones));
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
||||
|
||||
memset(env, 0, sizeof(dns_dtenv_t));
|
||||
|
||||
CHECK(isc_refcount_init(&env->refcount, 1));
|
||||
isc_refcount_init(&env->refcount, 1);
|
||||
CHECK(isc_stats_create(mctx, &env->stats, dns_dnstapcounter_max));
|
||||
env->path = isc_mem_strdup(mctx, path);
|
||||
if (env->path == NULL)
|
||||
|
||||
+1
-7
@@ -1354,13 +1354,7 @@ get_key_struct(const dns_name_t *name, unsigned int alg,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
result = isc_refcount_init(&key->refs, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_name_free(key->key_name, mctx);
|
||||
isc_mem_put(mctx, key->key_name, sizeof(dns_name_t));
|
||||
isc_mem_put(mctx, key, sizeof(dst_key_t));
|
||||
return (NULL);
|
||||
}
|
||||
isc_refcount_init(&key->refs, 1);
|
||||
isc_mem_attach(mctx, &key->mctx);
|
||||
key->key_alg = alg;
|
||||
key->key_flags = flags;
|
||||
|
||||
+3
-19
@@ -89,15 +89,8 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
|
||||
goto cleanup_rbt;
|
||||
}
|
||||
|
||||
result = isc_refcount_init(&keytable->active_nodes, 0);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_rwlock;
|
||||
}
|
||||
|
||||
result = isc_refcount_init(&keytable->references, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_active_nodes;
|
||||
}
|
||||
isc_refcount_init(&keytable->active_nodes, 0);
|
||||
isc_refcount_init(&keytable->references, 1);
|
||||
|
||||
keytable->mctx = NULL;
|
||||
isc_mem_attach(mctx, &keytable->mctx);
|
||||
@@ -106,12 +99,6 @@ dns_keytable_create(isc_mem_t *mctx, dns_keytable_t **keytablep) {
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup_active_nodes:
|
||||
isc_refcount_destroy(&keytable->active_nodes);
|
||||
|
||||
cleanup_rwlock:
|
||||
isc_rwlock_destroy(&keytable->rwlock);
|
||||
|
||||
cleanup_rbt:
|
||||
dns_rbt_destroy(&keytable->table);
|
||||
|
||||
@@ -798,7 +785,6 @@ dns_keynode_trust(dns_keynode_t *keynode) {
|
||||
|
||||
isc_result_t
|
||||
dns_keynode_create(isc_mem_t *mctx, dns_keynode_t **target) {
|
||||
isc_result_t result;
|
||||
dns_keynode_t *knode;
|
||||
|
||||
REQUIRE(target != NULL && *target == NULL);
|
||||
@@ -813,9 +799,7 @@ dns_keynode_create(isc_mem_t *mctx, dns_keynode_t **target) {
|
||||
knode->key = NULL;
|
||||
knode->next = NULL;
|
||||
|
||||
result = isc_refcount_init(&knode->refcount, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
isc_refcount_init(&knode->refcount, 1);
|
||||
|
||||
*target = knode;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
+1
-6
@@ -308,7 +308,6 @@ static isc_result_t
|
||||
nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
|
||||
dns_nta_t **target)
|
||||
{
|
||||
isc_result_t result;
|
||||
dns_nta_t *nta = NULL;
|
||||
dns_view_t *view;
|
||||
|
||||
@@ -328,11 +327,7 @@ nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
|
||||
dns_rdataset_init(&nta->rdataset);
|
||||
dns_rdataset_init(&nta->sigrdataset);
|
||||
|
||||
result = isc_refcount_init(&nta->refcount, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(view->mctx, nta, sizeof(dns_nta_t));
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&nta->refcount, 1);
|
||||
|
||||
nta->name = dns_fixedname_initname(&nta->fn);
|
||||
dns_name_copy(name, nta->name, NULL);
|
||||
|
||||
+1
-6
@@ -49,7 +49,6 @@ struct dns_order {
|
||||
isc_result_t
|
||||
dns_order_create(isc_mem_t *mctx, dns_order_t **orderp) {
|
||||
dns_order_t *order;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(orderp != NULL && *orderp == NULL);
|
||||
|
||||
@@ -60,11 +59,7 @@ dns_order_create(isc_mem_t *mctx, dns_order_t **orderp) {
|
||||
ISC_LIST_INIT(order->ents);
|
||||
|
||||
/* Implicit attach. */
|
||||
result = isc_refcount_init(&order->references, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(mctx, order, sizeof(*order));
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&order->references, 1);
|
||||
|
||||
order->mctx = NULL;
|
||||
isc_mem_attach(mctx, &order->mctx);
|
||||
|
||||
+1
-6
@@ -80,12 +80,7 @@ dns_portlist_create(isc_mem_t *mctx, dns_portlist_t **portlistp) {
|
||||
isc_mem_put(mctx, portlist, sizeof(*portlist));
|
||||
return (result);
|
||||
}
|
||||
result = isc_refcount_init(&portlist->refcount, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
DESTROYLOCK(&portlist->lock);
|
||||
isc_mem_put(mctx, portlist, sizeof(*portlist));
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&portlist->refcount, 1);
|
||||
portlist->list = NULL;
|
||||
portlist->allocated = 0;
|
||||
portlist->active = 0;
|
||||
|
||||
+5
-13
@@ -1268,11 +1268,9 @@ allocate_version(isc_mem_t *mctx, rbtdb_serial_t serial,
|
||||
if (version == NULL)
|
||||
return (NULL);
|
||||
version->serial = serial;
|
||||
result = isc_refcount_init(&version->references, references);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(mctx, version, sizeof(*version));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -8360,9 +8358,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
for (i = 0; i < (int)(rbtdb->node_lock_count); i++) {
|
||||
result = NODE_INITLOCK(&rbtdb->node_locks[i].lock);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
result = isc_refcount_init(&rbtdb->node_locks[i].references, 0);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
NODE_DESTROYLOCK(&rbtdb->node_locks[i].lock);
|
||||
isc_refcount_init(&rbtdb->node_locks[i].references, 0);
|
||||
}
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
while (i-- > 0) {
|
||||
@@ -8471,11 +8467,7 @@ dns_rbtdb_create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
||||
/*
|
||||
* Misc. Initialization.
|
||||
*/
|
||||
result = isc_refcount_init(&rbtdb->references, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
free_rbtdb(rbtdb, false, NULL);
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&rbtdb->references, 1);
|
||||
rbtdb->attributes = 0;
|
||||
rbtdb->task = NULL;
|
||||
rbtdb->serve_stale_ttl = 0;
|
||||
|
||||
+2
-8
@@ -1451,9 +1451,7 @@ dns_rpz_new_zones(dns_rpz_zones_t **rpzsp, char *rps_cstr,
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_mutex;
|
||||
|
||||
result = isc_refcount_init(&zones->refs, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_refcount;
|
||||
isc_refcount_init(&zones->refs, 1);
|
||||
|
||||
zones->rps_cstr = rps_cstr;
|
||||
zones->rps_cstr_size = rps_cstr_size;
|
||||
@@ -1490,7 +1488,6 @@ cleanup_rbt:
|
||||
isc_refcount_decrement(&zones->refs, NULL);
|
||||
isc_refcount_destroy(&zones->refs);
|
||||
|
||||
cleanup_refcount:
|
||||
DESTROYLOCK(&zones->maint_lock);
|
||||
|
||||
cleanup_mutex:
|
||||
@@ -1519,9 +1516,7 @@ dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp) {
|
||||
}
|
||||
|
||||
memset(zone, 0, sizeof(*zone));
|
||||
result = isc_refcount_init(&zone->refs, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_refcount;
|
||||
isc_refcount_init(&zone->refs, 1);
|
||||
|
||||
result = isc_timer_create(rpzs->timermgr, isc_timertype_inactive,
|
||||
NULL, NULL, rpzs->updater,
|
||||
@@ -1576,7 +1571,6 @@ cleanup_timer:
|
||||
isc_refcount_decrement(&zone->refs, NULL);
|
||||
isc_refcount_destroy(&zone->refs);
|
||||
|
||||
cleanup_refcount:
|
||||
isc_mem_put(zone->rpzs->mctx, zone, sizeof(*zone));
|
||||
|
||||
return (result);
|
||||
|
||||
+3
-4
@@ -331,9 +331,8 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
|
||||
refs = 1;
|
||||
if (ring != NULL)
|
||||
refs++;
|
||||
ret = isc_refcount_init(&tkey->refs, refs);
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
goto cleanup_creator;
|
||||
|
||||
isc_refcount_init(&tkey->refs, refs);
|
||||
|
||||
tkey->generated = generated;
|
||||
tkey->inception = inception;
|
||||
@@ -373,7 +372,7 @@ dns_tsigkey_createfromkey(const dns_name_t *name, const dns_name_t *algorithm,
|
||||
while (refs-- > 0)
|
||||
isc_refcount_decrement(&tkey->refs, NULL);
|
||||
isc_refcount_destroy(&tkey->refs);
|
||||
cleanup_creator:
|
||||
|
||||
if (tkey->key != NULL)
|
||||
dst_key_free(&tkey->key);
|
||||
if (tkey->creator != NULL) {
|
||||
|
||||
+1
-4
@@ -154,9 +154,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
view->rdclass = rdclass;
|
||||
view->frozen = false;
|
||||
view->task = NULL;
|
||||
result = isc_refcount_init(&view->references, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup_fwdtable;
|
||||
isc_refcount_init(&view->references, 1);
|
||||
view->weakrefs = 0;
|
||||
view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN|
|
||||
DNS_VIEWATTR_REQSHUTDOWN);
|
||||
@@ -316,7 +314,6 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
isc_refcount_decrement(&view->references, NULL);
|
||||
isc_refcount_destroy(&view->references);
|
||||
|
||||
cleanup_fwdtable:
|
||||
if (view->fwdtable != NULL)
|
||||
dns_fwdtable_destroy(&view->fwdtable);
|
||||
|
||||
|
||||
+1
-5
@@ -923,10 +923,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||
zone->db = NULL;
|
||||
zone->zmgr = NULL;
|
||||
ISC_LINK_INIT(zone, link);
|
||||
result = isc_refcount_init(&zone->erefs, 1); /* Implicit attach. */
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto free_dblock;
|
||||
}
|
||||
isc_refcount_init(&zone->erefs, 1); /* Implicit attach. */
|
||||
zone->irefs = 0;
|
||||
dns_name_init(&zone->origin, NULL);
|
||||
zone->strnamerd = NULL;
|
||||
@@ -1096,7 +1093,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
|
||||
isc_refcount_decrement(&zone->erefs, NULL);
|
||||
isc_refcount_destroy(&zone->erefs);
|
||||
|
||||
free_dblock:
|
||||
ZONEDB_DESTROYLOCK(&zone->dblock);
|
||||
|
||||
free_mutex:
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ OBJS = @ISC_EXTRA_OBJS@ pk11.@O@ pk11_result.@O@ \
|
||||
md5.@O@ mem.@O@ mutexblock.@O@ \
|
||||
netaddr.@O@ netscope.@O@ nonce.@O@ openssl_shim.@O@ pool.@O@ \
|
||||
parseint.@O@ portset.@O@ quota.@O@ radix.@O@ random.@O@ \
|
||||
ratelimiter.@O@ refcount.@O@ region.@O@ regex.@O@ result.@O@ \
|
||||
ratelimiter.@O@ region.@O@ regex.@O@ result.@O@ \
|
||||
rwlock.@O@ \
|
||||
serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ stats.@O@ \
|
||||
string.@O@ strtoul.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
|
||||
@@ -74,7 +74,7 @@ SRCS = @ISC_EXTRA_SRCS@ pk11.c pk11_result.c \
|
||||
md5.c mem.c mutexblock.c \
|
||||
netaddr.c netscope.c nonce.c openssl_shim.c pool.c \
|
||||
parseint.c portset.c quota.c radix.c random.c \
|
||||
ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \
|
||||
ratelimiter.c region.c regex.c result.c rwlock.c \
|
||||
serial.c sha1.c sha2.c sockaddr.c stats.c string.c \
|
||||
strtoul.c symtab.c task.c taskpool.c timer.c \
|
||||
tm.c version.c
|
||||
|
||||
@@ -43,7 +43,7 @@ ISC_LANG_BEGINDECLS
|
||||
*/
|
||||
|
||||
/*
|
||||
* isc_result_t
|
||||
* void
|
||||
* isc_refcount_init(isc_refcount_t *ref, unsigned int n);
|
||||
*
|
||||
* Initialize the reference counter. There will be 'n' initial references.
|
||||
@@ -95,9 +95,10 @@ ISC_LANG_BEGINDECLS
|
||||
* Sample implementations
|
||||
*/
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || defined(ISC_PLATFORM_HAVEXADD)
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC) || defined(ISC_PLATFORM_HAVEXADD)
|
||||
#define ISC_REFCOUNT_HAVEATOMIC 1
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE))
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC)
|
||||
#define ISC_REFCOUNT_HAVESTDATOMIC 1
|
||||
#endif
|
||||
|
||||
@@ -111,6 +112,8 @@ typedef struct isc_refcount {
|
||||
|
||||
#if defined(ISC_REFCOUNT_HAVESTDATOMIC)
|
||||
|
||||
#define isc_refcount_init(rp, n) atomic_init(&(rp)->refs, n)
|
||||
|
||||
#define isc_refcount_current(rp) \
|
||||
((unsigned int)(atomic_load_explicit(&(rp)->refs, \
|
||||
memory_order_relaxed)))
|
||||
@@ -150,6 +153,8 @@ typedef struct isc_refcount {
|
||||
|
||||
#else /* ISC_REFCOUNT_HAVESTDATOMIC */
|
||||
|
||||
#define isc_refcount_init(rp, n) isc_atomic_store(&(rp)->refs, n)
|
||||
|
||||
#define isc_refcount_current(rp) \
|
||||
((unsigned int)(isc_atomic_xadd(&(rp)->refs, 0)))
|
||||
#define isc_refcount_destroy(rp) ISC_REQUIRE(isc_refcount_current(rp) == 0)
|
||||
@@ -192,6 +197,12 @@ typedef struct isc_refcount {
|
||||
isc_mutex_t lock;
|
||||
} isc_refcount_t;
|
||||
|
||||
#define isc_refcount_init(rp, n) \
|
||||
do { \
|
||||
REQUIRE(isc_mutex_init(&(rp)->lock) == ISC_R_SUCCESS); \
|
||||
(rp)->refs = n; \
|
||||
} while(0);
|
||||
|
||||
/*% Destroys a reference counter. */
|
||||
#define isc_refcount_destroy(rp) \
|
||||
do { \
|
||||
@@ -259,6 +270,7 @@ typedef struct isc_refcount {
|
||||
int refs;
|
||||
} isc_refcount_t;
|
||||
|
||||
#define isc_refcount_init(rp, n) ((rp)->refs = n)
|
||||
#define isc_refcount_destroy(rp) ISC_REQUIRE((rp)->refs == 0)
|
||||
#define isc_refcount_current(rp) ((unsigned int)((rp)->refs))
|
||||
|
||||
@@ -292,9 +304,6 @@ typedef struct isc_refcount {
|
||||
|
||||
#endif /* ISC_PLATFORM_USETHREADS */
|
||||
|
||||
isc_result_t
|
||||
isc_refcount_init(isc_refcount_t *ref, unsigned int n);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_REFCOUNT_H */
|
||||
|
||||
@@ -35,9 +35,9 @@ typedef enum {
|
||||
} isc_rwlocktype_t;
|
||||
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || (defined(ISC_PLATFORM_HAVEXADD) && defined(ISC_PLATFORM_HAVECMPXCHG))
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC) || (defined(ISC_PLATFORM_HAVEXADD) && defined(ISC_PLATFORM_HAVECMPXCHG))
|
||||
#define ISC_RWLOCK_USEATOMIC 1
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE))
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC)
|
||||
#define ISC_RWLOCK_USESTDATOMIC 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* See the COPYRIGHT file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/refcount.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
isc_result_t
|
||||
isc_refcount_init(isc_refcount_t *ref, unsigned int n) {
|
||||
REQUIRE(ref != NULL);
|
||||
|
||||
ref->refs = n;
|
||||
#if defined(ISC_PLATFORM_USETHREADS) && !defined(ISC_REFCOUNT_HAVEATOMIC)
|
||||
return (isc_mutex_init(&ref->lock));
|
||||
#else
|
||||
return (ISC_R_SUCCESS);
|
||||
#endif
|
||||
}
|
||||
+4
-4
@@ -39,10 +39,10 @@
|
||||
* increment and store operations, just to make
|
||||
* the later macros simpler
|
||||
*/
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_LONG_LOCK_FREE)) || \
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC) || \
|
||||
(defined(ISC_PLATFORM_HAVEXADDQ) && defined(ISC_PLATFORM_HAVEATOMICSTOREQ))
|
||||
#define ISC_STATS_HAVEATOMICQ 1
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_LONG_LOCK_FREE))
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC)
|
||||
#define ISC_STATS_HAVESTDATOMICQ 1
|
||||
#endif
|
||||
#else
|
||||
@@ -72,9 +72,9 @@
|
||||
* Otherwise, just rely on standard 64-bit data types
|
||||
* and operations
|
||||
*/
|
||||
#if !ISC_STATS_HAVEATOMICQ && ((defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || defined(ISC_PLATFORM_HAVEXADD))
|
||||
#if !ISC_STATS_HAVEATOMICQ && (defined(ISC_PLATFORM_HAVESTDATOMIC) || defined(ISC_PLATFORM_HAVEXADD))
|
||||
#define ISC_STATS_USEMULTIFIELDS 1
|
||||
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE))
|
||||
#if defined(ISC_PLATFORM_HAVESTDATOMIC)
|
||||
#define ISC_STATS_HAVESTDATOMIC 1
|
||||
#endif
|
||||
#else
|
||||
|
||||
@@ -520,7 +520,6 @@ isc_ratelimiter_setpertic
|
||||
isc_ratelimiter_setpushpop
|
||||
isc_ratelimiter_shutdown
|
||||
isc_ratelimiter_stall
|
||||
isc_refcount_init
|
||||
isc_regex_validate
|
||||
isc_region_compare
|
||||
isc_resource_getcurlimit
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
isc_result_t
|
||||
cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
|
||||
isc_result_t result;
|
||||
cfg_aclconfctx_t *actx;
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
@@ -46,9 +45,7 @@ cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
|
||||
if (actx == NULL)
|
||||
return (ISC_R_NOMEMORY);
|
||||
|
||||
result = isc_refcount_init(&actx->references, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_refcount_init(&actx->references, 1);
|
||||
|
||||
actx->mctx = NULL;
|
||||
isc_mem_attach(mctx, &actx->mctx);
|
||||
@@ -60,10 +57,6 @@ cfg_aclconfctx_create(isc_mem_t *mctx, cfg_aclconfctx_t **ret) {
|
||||
|
||||
*ret = actx;
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
isc_mem_put(mctx, actx, sizeof(*actx));
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+3
-11
@@ -451,11 +451,7 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret) {
|
||||
pctx->mctx = NULL;
|
||||
isc_mem_attach(mctx, &pctx->mctx);
|
||||
|
||||
result = isc_refcount_init(&pctx->references, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_putanddetach(&pctx->mctx, pctx, sizeof(*pctx));
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&pctx->references, 1);
|
||||
|
||||
pctx->lctx = lctx;
|
||||
pctx->lexer = NULL;
|
||||
@@ -3064,7 +3060,6 @@ cfg_obj_line(const cfg_obj_t *obj) {
|
||||
|
||||
isc_result_t
|
||||
cfg_create_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|
||||
isc_result_t result;
|
||||
cfg_obj_t *obj;
|
||||
|
||||
REQUIRE(pctx != NULL);
|
||||
@@ -3080,11 +3075,8 @@ cfg_create_obj(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|
||||
obj->line = pctx->line;
|
||||
obj->pctx = pctx;
|
||||
|
||||
result = isc_refcount_init(&obj->references, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_put(pctx->mctx, obj, sizeof(cfg_obj_t));
|
||||
return (result);
|
||||
}
|
||||
isc_refcount_init(&obj->references, 1);
|
||||
|
||||
*ret = obj;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
+1
-8
@@ -50,9 +50,7 @@ ns_server_create(isc_mem_t *mctx, ns_matchview_t matchingview,
|
||||
|
||||
isc_mem_attach(mctx, &sctx->mctx);
|
||||
|
||||
result = isc_refcount_init(&sctx->references, 1);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto cleanup;
|
||||
isc_refcount_init(&sctx->references, 1);
|
||||
|
||||
CHECKFATAL(isc_quota_init(&sctx->xfroutquota, 10));
|
||||
CHECKFATAL(isc_quota_init(&sctx->tcpquota, 10));
|
||||
@@ -113,11 +111,6 @@ ns_server_create(isc_mem_t *mctx, ns_matchview_t matchingview,
|
||||
*sctxp = sctx;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
isc_mem_putanddetach(&sctx->mctx, sctx, sizeof(*sctx));
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user