]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Implemented getters/setters for HttpHdrCc::stale_if_error
authorFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 23 Sep 2011 08:36:42 +0000 (10:36 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Fri, 23 Sep 2011 08:36:42 +0000 (10:36 +0200)
Fixed formatting in HttpHdrCc.c

src/HttpHdrCc.cc
src/HttpHdrCc.h
src/refresh.cc

index a29388b9bb29a61583afd1255382b7067d2a158a..78962a8c25c3e55cfaec4f127452b30780c56cd3 100644 (file)
@@ -205,8 +205,7 @@ HttpHdrCc::parse(const String & str)
         case CC_STALE_IF_ERROR:
             if (!p || !httpHeaderParseInt(p, &cc->stale_if_error)) {
                 debugs(65, 2, "cc: invalid stale-if-error specs near '" << item << "'");
-                cc->stale_if_error = -1;
-                EBIT_CLR(cc->mask, type);
+                cc->setStaleIfError(STALE_IF_ERROR_UNSET);
             }
             break;
 
@@ -301,12 +300,14 @@ HttpHdrCc::setMaxAge(int max_age_)
     }
 }
 
-int32_t HttpHdrCc::getMaxAge() const
+int32_t
+HttpHdrCc::getMaxAge() const
 {
     return max_age;
 }
 
-void HttpHdrCc::setSMaxAge(int32_t s_maxage)
+void
+HttpHdrCc::setSMaxAge(int32_t s_maxage)
 {
        if (s_maxage >= 0) {
                EBIT_SET(mask, CC_S_MAXAGE);
@@ -317,12 +318,14 @@ void HttpHdrCc::setSMaxAge(int32_t s_maxage)
        }
 }
 
-int32_t HttpHdrCc::getSMaxAge() const
+int32_t
+HttpHdrCc::getSMaxAge() const
 {
        return s_maxage;
 }
 
-void HttpHdrCc::setMaxStale(int32_t max_stale)
+void
+HttpHdrCc::setMaxStale(int32_t max_stale)
 {
        if (max_stale>=0 || max_stale==MAX_STALE_ALWAYS) {
                EBIT_SET(mask,CC_MAX_STALE);
@@ -332,7 +335,26 @@ void HttpHdrCc::setMaxStale(int32_t max_stale)
                this->max_stale=MAX_STALE_UNSET;
        }
 }
-int32_t HttpHdrCc::getMaxStale() const
+int32_t
+HttpHdrCc::getMaxStale() const
 {
        return max_stale;
 }
+
+void
+HttpHdrCc::setStaleIfError(int32_t stale_if_error)
+{
+       if (stale_if_error >= 0) {
+        EBIT_SET(mask, CC_STALE_IF_ERROR);
+        this->stale_if_error=stale_if_error;
+       } else {
+        EBIT_CLR(mask, CC_STALE_IF_ERROR);
+        this->stale_if_error=STALE_IF_ERROR_UNSET;
+       }
+}
+
+int32_t
+HttpHdrCc::getStaleIfError() const
+{
+       return stale_if_error;
+}
index 768058f6ebadcfa243d0ae798497626d1363f3b0..6d8c6b3fbc236359d5549fca318821e85a6dfd49 100644 (file)
@@ -48,10 +48,11 @@ public:
        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
+       static const int32_t STALE_IF_ERROR_UNSET=-1; //stale_if_error is unset
 
     explicit HttpHdrCc() :
             mask(0), max_age(MAX_AGE_UNSET), s_maxage(S_MAXAGE_UNSET),
-            max_stale(MAX_STALE_UNSET), stale_if_error(0),
+            max_stale(MAX_STALE_UNSET), stale_if_error(STALE_IF_ERROR_UNSET),
             min_fresh(-1) {}
 
     void clear();
@@ -66,6 +67,9 @@ public:
     void setMaxStale(int32_t max_stale);
     int32_t getMaxStale() const;
 
+    void setStaleIfError(int32_t stale_if_error);
+    int32_t getStaleIfError() const;
+
     MEMPROXY_CLASS(HttpHdrCc);
 
     int32_t mask;
@@ -73,8 +77,8 @@ private:
     int32_t max_age;
     int32_t s_maxage;
     int32_t max_stale;
-public:
     int32_t stale_if_error;
+public:
     int32_t min_fresh;
     String other;
 };
index 924b253d47cfb75e9df1e9628fc34cdffb2c3d08..577d735706c8d42844a53fab5f8164eff194b820 100644 (file)
@@ -287,8 +287,8 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta)
 
     // stale-if-error requires any failure be passed thru when its period is over.
     if (request && entry->mem_obj && entry->mem_obj->getReply() && entry->mem_obj->getReply()->cache_control &&
-            EBIT_TEST(entry->mem_obj->getReply()->cache_control->mask, CC_STALE_IF_ERROR) &&
-            entry->mem_obj->getReply()->cache_control->stale_if_error < staleness) {
+               entry->mem_obj->getReply()->cache_control->getStaleIfError() != HttpHdrCc::STALE_IF_ERROR_UNSET &&
+            entry->mem_obj->getReply()->cache_control->getStaleIfError() < staleness) {
 
         debugs(22, 3, "refreshCheck: stale-if-error period expired.");
         request->flags.fail_on_validation_err = 1;