Fix code freeing cached non-A(AAA) records too early
authorRafał Miłecki <rafal@milecki.pl>
Mon, 20 Mar 2017 16:55:50 +0000 (17:55 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Mon, 20 Mar 2017 16:57:30 +0000 (17:57 +0100)
Fixes: f89986b67dd5 ("Fix refreshing cached A(AAA) records that expire")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
cache.c

diff --git a/cache.c b/cache.c
index 6ff2479a033cd06c4f9542efc5a6961ce7a93e60..0658e7e2f44c127b167db8f76bb87bff2e9686de 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -80,7 +80,8 @@ cache_gc_timer(struct uloop_timeout *timeout)
                        continue;
                /* Records other than A(AAA) are handled as services */
                if (r->type != TYPE_A && r->type != TYPE_AAAA) {
-                       cache_record_free(r);
+                       if (cache_is_expired(r->time, r->ttl, 100))
+                               cache_record_free(r);
                        continue;
                }
                if (r->refresh >= 100) {