]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #799: positive_dns_ttl ignored when using internal DNS client
authorhno <>
Sat, 3 Apr 2004 21:35:48 +0000 (21:35 +0000)
committerhno <>
Sat, 3 Apr 2004 21:35:48 +0000 (21:35 +0000)
The positive_dns_ttl directive is not used by the internal dns client (the
default). This patch changes it to at least be used as a upper limit on how
long DNS data may be cached.

src/fqdncache.cc
src/ipcache.cc

index 34ab2c5494d0ab869c112414cc89bfd458c01758..4074f3666954d22f8c1bf5435ac3940c1b8e2d1a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.157 2003/12/04 10:17:16 hno Exp $
+ * $Id: fqdncache.cc,v 1.158 2004/04/03 14:35:48 hno Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -311,7 +311,7 @@ fqdncacheParse(const char *inbuf)
     f.flags.negcached = 0;
     ttl = atoi(token);
 
-    if (ttl > 0)
+    if (ttl > 0 && ttl < Config.positiveDnsTtl)
         f.expires = squid_curtime + ttl;
     else
         f.expires = squid_curtime + Config.positiveDnsTtl;
@@ -368,7 +368,10 @@ fqdncacheParse(rfc1035_rr * answers, int nr)
 
         f.name_count = 1;
 
-        f.expires = squid_curtime + answers[k].ttl;
+        if ((int) answers[k].ttl < Config.positiveDnsTtl)
+            f.expires = squid_curtime + answers[k].ttl;
+        else
+            f.expires = squid_curtime + Config.positiveDnsTtl;
 
         return &f;
     }
index cf56486b8f147136d15c57f906bc7331a2083d9d..d562f5de6e576cb209a08633d0ccf4d07aa3fc49 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.242 2003/02/21 22:50:09 robertc Exp $
+ * $Id: ipcache.cc,v 1.243 2004/04/03 14:35:48 hno Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -320,7 +320,7 @@ ipcacheParse(const char *inbuf)
     i.flags.negcached = 0;
     ttl = atoi(token);
 
-    if (ttl > 0)
+    if (ttl > 0 && ttl < Config.positiveDnsTtl)
         i.expires = squid_curtime + ttl;
     else
         i.expires = squid_curtime + Config.positiveDnsTtl;
@@ -408,8 +408,12 @@ ipcacheParse(rfc1035_rr * answers, int nr)
         if (answers[k]._class != RFC1035_CLASS_IN)
             continue;
 
-        if (j == 0)
-            i.expires = squid_curtime + answers[k].ttl;
+        if (j == 0) {
+            if ((int) answers[k].ttl < Config.positiveDnsTtl)
+                i.expires = squid_curtime + answers[k].ttl;
+            else
+                i.expires = squid_curtime + Config.positiveDnsTtl;
+        }
 
         assert(answers[k].rdlength == 4);