]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix that unbound-control reload frees the rrset keys and returns
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 1 May 2018 14:00:06 +0000 (14:00 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 1 May 2018 14:00:06 +0000 (14:00 +0000)
  the memory pages to the system.

git-svn-id: file:///svn/unbound/trunk@4669 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/daemon.c
doc/Changelog
util/alloc.c
util/alloc.h

index 85ae1e0a15ac5f7fed7b53954b9cd6f624261eba..6820e1181451e72422bc2186d1c01c942dec3cee 100644 (file)
@@ -704,6 +704,7 @@ daemon_cleanup(struct daemon* daemon)
        free(daemon->workers);
        daemon->workers = NULL;
        daemon->num = 0;
+       alloc_clear_special(&daemon->superalloc);
 #ifdef USE_DNSTAP
        dt_delete(daemon->dtenv);
        daemon->dtenv = NULL;
index 62534161c95371a88a421508ac1a9adfeb96f1a1..ac8c00c9c5caf26de2771aaa246ceef79e5cbc17 100644 (file)
@@ -1,3 +1,7 @@
+1 May 2018: Wouter
+       - Fix that unbound-control reload frees the rrset keys and returns
+         the memory pages to the system.
+
 30 April 2018: Wouter
        - Fix spelling error in man page and note defaults as no instead of
          off.
index 2c6e1a23f6c02fe1be96f799fca52f36df3c8618..908b1f42361f2bce89c68980a5572f4241802772 100644 (file)
@@ -126,10 +126,40 @@ alloc_init(struct alloc_cache* alloc, struct alloc_cache* super,
        }
 }
 
+/** free the special list */
+static void
+alloc_clear_special_list(struct alloc_cache* alloc)
+{
+       alloc_special_type* p, *np;
+       /* free */
+       p = alloc->quar;
+       while(p) {
+               np = alloc_special_next(p);
+               /* deinit special type */
+               lock_rw_destroy(&p->entry.lock);
+               free(p);
+               p = np;
+       }
+}
+
+void
+alloc_clear_special(struct alloc_cache* alloc)
+{
+       if(!alloc->super) {
+               lock_quick_lock(&alloc->lock);
+       }
+       alloc_clear_special_list(alloc);
+       alloc->quar = 0;
+       alloc->num_quar = 0;
+       if(!alloc->super) {
+               lock_quick_unlock(&alloc->lock);
+       }
+}
+
 void 
 alloc_clear(struct alloc_cache* alloc)
 {
-       alloc_special_type* p, *np;
+       alloc_special_type* p;
        struct regional* r, *nr;
        if(!alloc)
                return;
@@ -147,15 +177,7 @@ alloc_clear(struct alloc_cache* alloc)
                alloc->super->num_quar += alloc->num_quar;
                lock_quick_unlock(&alloc->super->lock);
        } else {
-               /* free */
-               p = alloc->quar;
-               while(p) {
-                       np = alloc_special_next(p);
-                       /* deinit special type */
-                       lock_rw_destroy(&p->entry.lock);
-                       free(p);
-                       p = np;
-               }
+               alloc_clear_special_list(alloc);
        }
        alloc->quar = 0;
        alloc->num_quar = 0;
index 9839a455017565419ea38e5a42c998d91c4f012d..ee03b074e39d4e22ca3db0d3980cfc2a53a2778d 100644 (file)
@@ -115,6 +115,14 @@ void alloc_init(struct alloc_cache* alloc, struct alloc_cache* super,
  */
 void alloc_clear(struct alloc_cache* alloc);
 
+/**
+ * Free the special alloced items.  The rrset and message caches must be
+ * empty, there must be no more references to rrset pointers into the
+ * rrset cache.
+ * @param alloc: the special allocs are freed.
+ */
+void alloc_clear_special(struct alloc_cache* alloc);
+
 /**
  * Get a new special_type element.
  * @param alloc: where to alloc it.