From: Ondřej Surý Date: Fri, 17 Aug 2018 10:54:27 +0000 (+0200) Subject: Remove checks for atomic rwlock from rbtdb.cz and zone.c X-Git-Tag: v9.13.3~28^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fbbf09d213bad58fd429cc2bd7a4c903dbf1608;p=thirdparty%2Fbind9.git Remove checks for atomic rwlock from rbtdb.cz and zone.c --- diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 4a52dfc8fff..ab21465b615 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -134,31 +134,10 @@ typedef uint32_t rbtdb_rdatatype_t; #define RBTDB_RDATATYPE_NCACHEANY \ RBTDB_RDATATYPE_VALUE(0, dns_rdatatype_any) -/* - * We use rwlock for DB lock only when ISC_RWLOCK_USEATOMIC is non 0. - * Using rwlock is effective with regard to lookup performance only when - * it is implemented in an efficient way. - * Otherwise, it is generally wise to stick to the simple locking since rwlock - * would require more memory or can even make lookups slower due to its own - * overhead (when it internally calls mutex locks). - */ -#ifdef ISC_RWLOCK_USEATOMIC -#define DNS_RBTDB_USERWLOCK 1 -#else -#define DNS_RBTDB_USERWLOCK 0 -#endif - -#if DNS_RBTDB_USERWLOCK #define RBTDB_INITLOCK(l) isc_rwlock_init((l), 0, 0) #define RBTDB_DESTROYLOCK(l) isc_rwlock_destroy(l) #define RBTDB_LOCK(l, t) RWLOCK((l), (t)) #define RBTDB_UNLOCK(l, t) RWUNLOCK((l), (t)) -#else -#define RBTDB_INITLOCK(l) isc_mutex_init(l) -#define RBTDB_DESTROYLOCK(l) DESTROYLOCK(l) -#define RBTDB_LOCK(l, t) LOCK(l) -#define RBTDB_UNLOCK(l, t) UNLOCK(l) -#endif /* * Since node locking is sensitive to both performance and memory footprint, @@ -179,7 +158,6 @@ typedef uint32_t rbtdb_rdatatype_t; * Note that we cannot use NODE_LOCK()/NODE_UNLOCK() wherever the protected * section is also protected by NODE_STRONGLOCK(). */ -#if defined(ISC_RWLOCK_USEATOMIC) && defined(DNS_RBT_USEISCREFCOUNT) typedef isc_rwlock_t nodelock_t; #define NODE_INITLOCK(l) isc_rwlock_init((l), 0, 0) @@ -193,21 +171,6 @@ typedef isc_rwlock_t nodelock_t; #define NODE_WEAKLOCK(l, t) NODE_LOCK(l, t) #define NODE_WEAKUNLOCK(l, t) NODE_UNLOCK(l, t) #define NODE_WEAKDOWNGRADE(l) isc_rwlock_downgrade(l) -#else -typedef isc_mutex_t nodelock_t; - -#define NODE_INITLOCK(l) isc_mutex_init(l) -#define NODE_DESTROYLOCK(l) DESTROYLOCK(l) -#define NODE_LOCK(l, t) LOCK(l) -#define NODE_UNLOCK(l, t) UNLOCK(l) -#define NODE_TRYUPGRADE(l) ISC_R_SUCCESS - -#define NODE_STRONGLOCK(l) LOCK(l) -#define NODE_STRONGUNLOCK(l) UNLOCK(l) -#define NODE_WEAKLOCK(l, t) ((void)0) -#define NODE_WEAKUNLOCK(l, t) ((void)0) -#define NODE_WEAKDOWNGRADE(l) ((void)0) -#endif /*% * Whether to rate-limit updating the LRU to avoid possible thread contention. @@ -466,11 +429,7 @@ struct dns_rbtdb { /* Unlocked. */ dns_db_t common; /* Locks the data in this struct */ -#if DNS_RBTDB_USERWLOCK isc_rwlock_t lock; -#else - isc_mutex_t lock; -#endif /* Locks the tree structure (prevents nodes appearing/disappearing) */ isc_rwlock_t tree_lock; /* Locks for individual tree nodes */ @@ -4474,10 +4433,6 @@ check_stale_header(dns_rbtnode_t *node, rdatasetheader_t *header, rbtdb_search_t *search, rdatasetheader_t **header_prev) { -#if !defined(ISC_RWLOCK_USEATOMIC) || !defined(DNS_RBT_USEISCREFCOUNT) - UNUSED(lock); -#endif - if (!ACTIVE(header, search->now)) { dns_ttl_t stale = header->rdh_ttl + search->rbtdb->serve_stale_ttl; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 58eb45d2a16..3dc5231702c 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -177,17 +177,10 @@ typedef struct dns_include dns_include_t; do { result = isc_mutex_trylock(&(z)->lock); } while (0) #endif -#ifdef ISC_RWLOCK_USEATOMIC #define ZONEDB_INITLOCK(l) isc_rwlock_init((l), 0, 0) #define ZONEDB_DESTROYLOCK(l) isc_rwlock_destroy(l) #define ZONEDB_LOCK(l, t) RWLOCK((l), (t)) #define ZONEDB_UNLOCK(l, t) RWUNLOCK((l), (t)) -#else -#define ZONEDB_INITLOCK(l) isc_mutex_init(l) -#define ZONEDB_DESTROYLOCK(l) DESTROYLOCK(l) -#define ZONEDB_LOCK(l, t) LOCK(l) -#define ZONEDB_UNLOCK(l, t) UNLOCK(l) -#endif #ifdef ENABLE_AFL extern bool dns_fuzzing_resolver; @@ -203,11 +196,7 @@ struct dns_zone { isc_mem_t *mctx; isc_refcount_t erefs; -#ifdef ISC_RWLOCK_USEATOMIC isc_rwlock_t dblock; -#else - isc_mutex_t dblock; -#endif dns_db_t *db; /* Locked by dblock */ /* Locked */