]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorMark Andrews <marka@isc.org>
Thu, 15 Nov 2001 00:37:57 +0000 (00:37 +0000)
committerMark Andrews <marka@isc.org>
Thu, 15 Nov 2001 00:37:57 +0000 (00:37 +0000)
Partial fix for RT #2053.  The potential for deadlock still exists,
but it is much less likely to occur because we now only take the ADB lock when
the
external reference count reaches zero, not every time it is decremented.
Althought this does not actually fix the bug, it at least lets us make
progress on testing fixes for other bugs affecting shutdown of multithreaded
servers.

lib/dns/adb.c

index a53904b5903bbf243975f159f688a92c4457a7dc..6eff3b5de0e606e508f07bfa6177cb43636c7980 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: adb.c,v 1.162.2.9 2001/11/12 22:30:30 marka Exp $ */
+/* $Id: adb.c,v 1.162.2.10 2001/11/15 00:37:57 marka Exp $ */
 
 /*
  * Implementation notes
@@ -303,7 +303,6 @@ static void print_find_list(FILE *, dns_adbname_t *);
 static void print_fetch_list(FILE *, dns_adbname_t *);
 static inline void dec_adb_irefcnt(dns_adb_t *);
 static inline void inc_adb_erefcnt(dns_adb_t *);
-static inline void dec_adb_erefcnt(dns_adb_t *, isc_boolean_t);
 static inline void inc_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
                                    isc_boolean_t);
 static inline void dec_entry_refcnt(dns_adb_t *, dns_adbentry_t *,
@@ -1210,27 +1209,6 @@ inc_adb_erefcnt(dns_adb_t *adb) {
        UNLOCK(&adb->reflock);
 }
 
-static inline void
-dec_adb_erefcnt(dns_adb_t *adb, isc_boolean_t lock) {
-       isc_boolean_t zeroerefcnt;
-
-       if (lock)
-               LOCK(&adb->lock);
-
-       INSIST(adb->erefcnt > 0);
-
-       LOCK(&adb->reflock);
-       adb->erefcnt--;
-       zeroerefcnt = ISC_TF(adb->erefcnt == 0);
-       UNLOCK(&adb->reflock);
-
-       if (zeroerefcnt)
-               check_exit(adb);
-
-       if (lock)
-               UNLOCK(&adb->lock);
-}
-
 static inline void
 inc_entry_refcnt(dns_adb_t *adb, dns_adbentry_t *entry, isc_boolean_t lock) {
        int bucket;
@@ -2357,17 +2335,26 @@ dns_adb_attach(dns_adb_t *adb, dns_adb_t **adbx) {
 void
 dns_adb_detach(dns_adb_t **adbx) {
        dns_adb_t *adb;
+       isc_boolean_t zeroerefcnt;
 
        REQUIRE(adbx != NULL && DNS_ADB_VALID(*adbx));
 
        adb = *adbx;
        *adbx = NULL;
 
-       LOCK(&adb->lock);
-       dec_adb_erefcnt(adb, ISC_FALSE);
-       if (adb->erefcnt == 0)
+       INSIST(adb->erefcnt > 0);
+
+       LOCK(&adb->reflock);
+       adb->erefcnt--;
+       zeroerefcnt = ISC_TF(adb->erefcnt == 0);
+       UNLOCK(&adb->reflock);
+
+       if (zeroerefcnt) {
+               LOCK(&adb->lock);
+               check_exit(adb);
                INSIST(adb->shutting_down);
-       UNLOCK(&adb->lock);
+               UNLOCK(&adb->lock);
+       }
 }
 
 void