From: Francesco Chemolli Date: Sun, 25 Sep 2011 13:06:40 +0000 (+0200) Subject: Created getters and setters for HttpHdrCc::min_fresh X-Git-Tag: BumpSslServerFirst.take01~126^2~16^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=422acb7fdda6b78b8e75f505f8bd2739a56ae7dc;p=thirdparty%2Fsquid.git Created getters and setters for HttpHdrCc::min_fresh --- diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index 78962a8c25..3359f01520 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -196,8 +196,7 @@ HttpHdrCc::parse(const String & str) if (!p || !httpHeaderParseInt(p, &cc->min_fresh)) { debugs(65, 2, "cc: invalid min-fresh specs near '" << item << "'"); - cc->min_fresh = -1; - EBIT_CLR(cc->mask, type); + cc->setMinFresh(MIN_FRESH_UNSET); } break; @@ -252,7 +251,7 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p) packerPrintf(p, "=%d", (int) cc->getMaxStale()); if (flag == CC_MIN_FRESH) - packerPrintf(p, "=%d", (int) cc->min_fresh); + packerPrintf(p, "=%d", (int) cc->getMinFresh()); ++pcount; } @@ -358,3 +357,21 @@ HttpHdrCc::getStaleIfError() const { return stale_if_error; } + +void +HttpHdrCc::setMinFresh(int32_t min_fresh) +{ + if (min_fresh >= 0) { + EBIT_SET(mask, CC_MIN_FRESH); + this->min_fresh=min_fresh; + } else { + EBIT_CLR(mask, CC_MIN_FRESH); + this->min_fresh=STALE_IF_ERROR_UNSET; + } +} + +int32_t +HttpHdrCc::getMinFresh() const +{ + return min_fresh; +} diff --git a/src/HttpHdrCc.h b/src/HttpHdrCc.h index 6d8c6b3fbc..f9c9af85a7 100644 --- a/src/HttpHdrCc.h +++ b/src/HttpHdrCc.h @@ -49,11 +49,12 @@ public: static const int32_t MAX_STALE_UNSET=-1; //max-stale is unset static const int32_t MAX_STALE_ALWAYS=-2; //max-stale is set to no value static const int32_t STALE_IF_ERROR_UNSET=-1; //stale_if_error is unset + static const int32_t MIN_FRESH_UNSET=-1; //min_fresh is unset explicit HttpHdrCc() : mask(0), max_age(MAX_AGE_UNSET), s_maxage(S_MAXAGE_UNSET), max_stale(MAX_STALE_UNSET), stale_if_error(STALE_IF_ERROR_UNSET), - min_fresh(-1) {} + min_fresh(MIN_FRESH_UNSET) {} void clear(); bool parse(const String & s); @@ -70,6 +71,9 @@ public: void setStaleIfError(int32_t stale_if_error); int32_t getStaleIfError() const; + void setMinFresh(int32_t min_fresh); + int32_t getMinFresh() const; + MEMPROXY_CLASS(HttpHdrCc); int32_t mask; @@ -78,8 +82,8 @@ private: int32_t s_maxage; int32_t max_stale; int32_t stale_if_error; -public: int32_t min_fresh; +public: String other; }; diff --git a/src/refresh.cc b/src/refresh.cc index 577d735706..abb79c36ce 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -268,14 +268,15 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) if (request && !request->flags.ignore_cc) { const HttpHdrCc *const cc = request->cache_control; - if (cc && cc->min_fresh > 0) { + const int32_t minFresh=cc->getMinFresh(); + if (cc && minFresh!=HttpHdrCc::MIN_FRESH_UNSET) { debugs(22, 3, "\tage + min-fresh:\t" << age << " + " << - cc->min_fresh << " = " << age + cc->min_fresh); + minFresh << " = " << age + minFresh); debugs(22, 3, "\tcheck_time + min-fresh:\t" << check_time << " + " - << cc->min_fresh << " = " << - mkrfc1123(check_time + cc->min_fresh)); - age += cc->min_fresh; - check_time += cc->min_fresh; + << minFresh << " = " << + mkrfc1123(check_time + minFresh)); + age += minFresh; + check_time += minFresh; } }