From: hno <> Date: Sat, 3 Apr 2004 21:35:48 +0000 (+0000) Subject: Bug #799: positive_dns_ttl ignored when using internal DNS client X-Git-Tag: SQUID_3_0_PRE4~1127 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5c56ab974a74c71e75b3f4617408063e112ff21f;p=thirdparty%2Fsquid.git Bug #799: positive_dns_ttl ignored when using internal DNS client 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. --- diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 34ab2c5494..4074f36669 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -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; } diff --git a/src/ipcache.cc b/src/ipcache.cc index cf56486b8f..d562f5de6e 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -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);