]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove checks for atomic rwlock from rbtdb.cz and zone.c
authorOndřej Surý <ondrej@sury.org>
Fri, 17 Aug 2018 10:54:27 +0000 (12:54 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 28 Aug 2018 10:15:39 +0000 (12:15 +0200)
lib/dns/rbtdb.c
lib/dns/zone.c

index 4a52dfc8fff294de62eef6618d3c331a653df662..ab21465b6158cb454070110d60d9689a2de91270 100644 (file)
@@ -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;
index 58eb45d2a163c0535d115c0c8cf6466d8e4730a8..3dc5231702c93796cb780b3194d62c8b09bc89da 100644 (file)
@@ -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 */