]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Created getters and setters for HttpHdrCc::min_fresh
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sun, 25 Sep 2011 13:06:40 +0000 (15:06 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sun, 25 Sep 2011 13:06:40 +0000 (15:06 +0200)
src/HttpHdrCc.cc
src/HttpHdrCc.h
src/refresh.cc

index 78962a8c25c3e55cfaec4f127452b30780c56cd3..3359f015205381fc792a6f206c1043148410549f 100644 (file)
@@ -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;
+}
index 6d8c6b3fbc236359d5549fca318821e85a6dfd49..f9c9af85a742f4ba27e0051a37b0f3d62d696405 100644 (file)
@@ -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;
 };
 
index 577d735706c8d42844a53fab5f8164eff194b820..abb79c36ce2ba4ab1c24808555e9770cc8aaff4c 100644 (file)
@@ -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;
         }
     }