]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorBrian Wellington <source@isc.org>
Fri, 9 Feb 2001 01:01:55 +0000 (01:01 +0000)
committerBrian Wellington <source@isc.org>
Fri, 9 Feb 2001 01:01:55 +0000 (01:01 +0000)
 733.   [bug]           Reference counts of dns_acl_t objects need to be
                        locked but were not. [RT #801]

CHANGES
lib/dns/acl.c
lib/dns/include/dns/acl.h

diff --git a/CHANGES b/CHANGES
index 92ec53850cdc8a0540ffc446e7877bf4a9f9cd57..ec7b36292a3f3c65d6139600267b403ac951c867 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,7 @@
 
+ 733.  [bug]           Reference counts of dns_acl_t objects need to be
+                       locked but were not. [RT #801]
+
  708.  [bug]           When building with --with-openssl, the openssl headers
                        included should not be used. [RT #702]
 
index 850711acf55ad0b95e39c29048b60d3ed9bbcef6..fcb997b69019b66616753c604f5f73568122ef93 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: acl.c,v 1.17.4.1 2001/01/09 22:43:21 bwelling Exp $ */
+/* $Id: acl.c,v 1.17.4.2 2001/02/09 01:01:54 bwelling Exp $ */
 
 #include <config.h>
 
@@ -41,7 +41,7 @@ dns_acl_create(isc_mem_t *mctx, int n, dns_acl_t **target) {
                return (ISC_R_NOMEMORY);
        acl->mctx = mctx;
        acl->name = NULL;
-       acl->refcount = 1;
+       isc_refcount_init(&acl->refcount, 1);
        acl->elements = NULL;
        acl->alloc = 0;
        acl->length = 0;
@@ -235,8 +235,7 @@ dns_aclelement_match(isc_netaddr_t *reqaddr,
 void
 dns_acl_attach(dns_acl_t *source, dns_acl_t **target) {
        REQUIRE(DNS_ACL_VALID(source));
-       INSIST(source->refcount > 0);
-       source->refcount++;
+       isc_refcount_increment(&source->refcount, NULL);
        *target = source;
 }
 
@@ -261,6 +260,7 @@ destroy(dns_acl_t *dacl) {
                            dacl->alloc * sizeof(dns_aclelement_t));
        if (dacl->name != NULL)
                isc_mem_free(dacl->mctx, dacl->name);
+       isc_refcount_destroy(&dacl->refcount);
        dacl->magic = 0;
        isc_mem_put(dacl->mctx, dacl, sizeof(*dacl));
 }
@@ -268,10 +268,10 @@ destroy(dns_acl_t *dacl) {
 void
 dns_acl_detach(dns_acl_t **aclp) {
        dns_acl_t *acl = *aclp;
+       unsigned int refs;
        REQUIRE(DNS_ACL_VALID(acl));
-       INSIST(acl->refcount > 0);
-       acl->refcount--;
-       if (acl->refcount == 0)
+       isc_refcount_decrement(&acl->refcount, &refs);
+       if (refs == 0)
                destroy(acl);
        *aclp = NULL;
 }
index 0f462469b03ccb70bdddef237e42445dfc22873d..443fd0d07fe524478ce4b9d1d944a4d5c6dbf52d 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: acl.h,v 1.16.4.1 2001/01/09 22:45:01 bwelling Exp $ */
+/* $Id: acl.h,v 1.16.4.2 2001/02/09 01:01:55 bwelling Exp $ */
 
 #ifndef DNS_ACL_H
 #define DNS_ACL_H 1
@@ -35,6 +35,7 @@
 #include <isc/lang.h>
 #include <isc/magic.h>
 #include <isc/netaddr.h>
+#include <isc/refcount.h>
 
 #include <dns/name.h>
 #include <dns/types.h>
@@ -72,7 +73,7 @@ struct dns_aclelement {
 struct dns_acl {
        isc_uint32_t            magic;
        isc_mem_t               *mctx;
-       unsigned int            refcount;
+       isc_refcount_t          refcount;
        dns_aclelement_t        *elements;
        unsigned int            alloc;          /* Elements allocated */
        unsigned int            length;         /* Elements initialized */