From: Francesco Chemolli Date: Thu, 22 Sep 2011 13:59:53 +0000 (+0200) Subject: implemented getters and setters for HttpHdrCc::max_stale X-Git-Tag: BumpSslServerFirst.take01~126^2~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b14a084a5f5ea07b0c84e007347d74a0aefc618c;p=thirdparty%2Fsquid.git implemented getters and setters for HttpHdrCc::max_stale --- diff --git a/src/HttpHdrCc.cc b/src/HttpHdrCc.cc index 8fa7d80329..a29388b9bb 100644 --- a/src/HttpHdrCc.cc +++ b/src/HttpHdrCc.cc @@ -187,7 +187,7 @@ HttpHdrCc::parse(const String & str) if (!p || !httpHeaderParseInt(p, &cc->max_stale)) { debugs(65, 2, "cc: max-stale directive is valid without value"); - cc->max_stale = -1; + cc->setMaxStale(MAX_STALE_ALWAYS); } break; @@ -249,8 +249,8 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p) if (flag == CC_S_MAXAGE) packerPrintf(p, "=%d", (int) cc->getSMaxAge()); - if (flag == CC_MAX_STALE && cc->max_stale >= 0) - packerPrintf(p, "=%d", (int) cc->max_stale); + if (flag == CC_MAX_STALE && cc->getMaxStale() >= 0) + packerPrintf(p, "=%d", (int) cc->getMaxStale()); if (flag == CC_MIN_FRESH) packerPrintf(p, "=%d", (int) cc->min_fresh); @@ -312,8 +312,8 @@ void HttpHdrCc::setSMaxAge(int32_t s_maxage) EBIT_SET(mask, CC_S_MAXAGE); this->s_maxage=s_maxage; } else { - this->s_maxage=S_MAXAGE_UNSET; EBIT_CLR(mask, CC_S_MAXAGE); + this->s_maxage=S_MAXAGE_UNSET; } } @@ -321,3 +321,18 @@ int32_t HttpHdrCc::getSMaxAge() const { return s_maxage; } + +void HttpHdrCc::setMaxStale(int32_t max_stale) +{ + if (max_stale>=0 || max_stale==MAX_STALE_ALWAYS) { + EBIT_SET(mask,CC_MAX_STALE); + this->max_stale=max_stale; + } else { + EBIT_CLR(mask, CC_MAX_STALE); + this->max_stale=MAX_STALE_UNSET; + } +} +int32_t HttpHdrCc::getMaxStale() const +{ + return max_stale; +} diff --git a/src/HttpHdrCc.h b/src/HttpHdrCc.h index a952b247cc..768058f6eb 100644 --- a/src/HttpHdrCc.h +++ b/src/HttpHdrCc.h @@ -45,11 +45,13 @@ class HttpHdrCc public: static const int32_t MAX_AGE_UNSET=-1; //max-age is unset - static const int32_t S_MAXAGE_UNSET=-1; //max-age is unset + static const int32_t S_MAXAGE_UNSET=-1; //s-maxage is unset + 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 explicit HttpHdrCc() : mask(0), max_age(MAX_AGE_UNSET), s_maxage(S_MAXAGE_UNSET), - max_stale(-1), stale_if_error(0), + max_stale(MAX_STALE_UNSET), stale_if_error(0), min_fresh(-1) {} void clear(); @@ -61,6 +63,8 @@ public: void setSMaxAge(int32_t s_maxage); int32_t getSMaxAge() const; + void setMaxStale(int32_t max_stale); + int32_t getMaxStale() const; MEMPROXY_CLASS(HttpHdrCc); @@ -68,8 +72,8 @@ public: private: int32_t max_age; int32_t s_maxage; -public: int32_t max_stale; +public: int32_t stale_if_error; int32_t min_fresh; String other; diff --git a/src/refresh.cc b/src/refresh.cc index 704eb3d81f..924b253d47 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -354,12 +354,12 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) } } - if (EBIT_TEST(cc->mask, CC_MAX_STALE) && staleness > -1) { - if (cc->max_stale < 0) { + if (cc->getMaxStale()>=0 && staleness > -1) { + if (cc->getMaxStale()==HttpHdrCc::MAX_STALE_ALWAYS) { /* max-stale directive without a value */ debugs(22, 3, "refreshCheck: NO: max-stale wildcard"); return FRESH_REQUEST_MAX_STALE_ALL; - } else if (staleness < cc->max_stale) { + } else if (staleness < cc->getMaxStale()) { debugs(22, 3, "refreshCheck: NO: staleness < max-stale"); return FRESH_REQUEST_MAX_STALE_VALUE; }