--------------------- PatchSet 4049 Date: 2007/02/14 06:44:28 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Polished TTL handling to make sure we use the default TTL when the ICAP server did not provide an explicit value or if we failed to communicate with the server. The latter case may not have been handled correctly before. Members: src/ICAP/ICAPOptions.cc:1.1.2.3->1.1.2.4 src/ICAP/ICAPOptions.h:1.1.2.3->1.1.2.4 Index: squid3/src/ICAP/ICAPOptions.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPOptions.cc,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/ICAP/ICAPOptions.cc 25 Oct 2006 04:55:33 -0000 1.1.2.3 +++ squid3/src/ICAP/ICAPOptions.cc 14 Feb 2007 06:44:28 -0000 1.1.2.4 @@ -57,10 +57,16 @@ return squid_curtime <= expire(); } +int ICAPOptions::ttl() const +{ + Must(valid()); + return theTTL >= 0 ? theTTL : TheICAPConfig.default_options_ttl; +} + time_t ICAPOptions::expire() const { Must(valid()); - return theTTL >= 0 ? theTimestamp + theTTL : -1; + return theTimestamp + ttl(); } void ICAPOptions::configure(const HttpReply *reply) @@ -92,9 +98,6 @@ cfgIntHeader(h, "Options-TTL", theTTL); - if (theTTL < 0) - theTTL = TheICAPConfig.default_options_ttl; - theTimestamp = h->getTime(HDR_DATE); if (theTimestamp < 0) Index: squid3/src/ICAP/ICAPOptions.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPOptions.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/ICAP/ICAPOptions.h 25 Oct 2006 04:55:33 -0000 1.1.2.3 +++ squid3/src/ICAP/ICAPOptions.h 14 Feb 2007 06:44:28 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: ICAPOptions.h,v 1.1.2.3 2006/10/25 04:55:33 rousskov Exp $ + * $Id: ICAPOptions.h,v 1.1.2.4 2007/02/14 06:44:28 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -35,7 +35,7 @@ #define SQUID_ICAPOPTIONS_H #include "squid.h" -#include "ICAPClient.h" +#include "ICAPServiceRep.h" class wordlist; @@ -57,11 +57,10 @@ bool valid() const; bool fresh() const; + int ttl() const; time_t expire() const; time_t timestamp() const { return theTimestamp; }; - int ttl() const { return theTTL; }; - typedef enum { xferNone, xferPreview, xferIgnore, xferComplete } TransferKind; TransferKind transferKind(const String &urlPath) const;