trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [1/2] trafficserver git commit: TS-2080 Remove arbitrary 1 year max age limit on the cache, use configuration option
Date Thu, 21 May 2015 01:38:30 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master edc8fbc92 -> 1781a6815


TS-2080 Remove arbitrary 1 year max age limit on the cache, use configuration option


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bdca37f0
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bdca37f0
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bdca37f0

Branch: refs/heads/master
Commit: bdca37f0edef7a0b7e5043ea890528d09fcd77c2
Parents: edc8fbc
Author: Leif Hedstrom <zwoop@apache.org>
Authored: Tue May 12 08:49:48 2015 -0600
Committer: Leif Hedstrom <zwoop@apache.org>
Committed: Wed May 20 19:37:45 2015 -0600

----------------------------------------------------------------------
 proxy/http/HttpTransact.cc      | 14 +++++++-------
 proxy/http/HttpTransact.h       |  1 -
 proxy/http/HttpTransactCache.cc |  7 ++++---
 proxy/http/HttpTransactCache.h  |  4 ++++
 4 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bdca37f0/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index a923d6e..1149d23 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -7098,7 +7098,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response,
ti
       freshness_limit = (int)response->get_cooked_cc_max_age();
       DebugTxn("http_match", "calculate_document_freshness_limit --- max_age set, freshness_limit
= %d", freshness_limit);
     }
-    freshness_limit = min(max(0, freshness_limit), NUM_SECONDS_IN_ONE_YEAR);
+    freshness_limit = min(max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
   } else {
     date_set = last_modified_set = false;
 
@@ -7135,7 +7135,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response,
ti
       DebugTxn("http_match", "calculate_document_freshness_limit --- Expires: %" PRId64 ",
Date: %" PRId64 ", freshness_limit = %d",
                (int64_t)expires_value, (int64_t)date_value, freshness_limit);
 
-      freshness_limit = min(max(0, freshness_limit), NUM_SECONDS_IN_ONE_YEAR);
+      freshness_limit = min(max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
     } else {
       last_modified_value = 0;
       if (response->presence(MIME_PRESENCE_LAST_MODIFIED)) {
@@ -7172,7 +7172,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response,
ti
 
   // The freshness limit must always fall within the min and max guaranteed bounds.
   min_freshness_bounds = max((MgmtInt)0, s->txn_conf->cache_guaranteed_min_lifetime);
-  max_freshness_bounds = min((MgmtInt)NUM_SECONDS_IN_ONE_YEAR, s->txn_conf->cache_guaranteed_max_lifetime);
+  max_freshness_bounds = s->txn_conf->cache_guaranteed_max_lifetime;
 
   // Heuristic freshness can be more strict.
   if (*heuristic) {
@@ -7205,7 +7205,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response,
ti
 int
 HttpTransact::calculate_freshness_fuzz(State *s, int fresh_limit)
 {
-  static double LOG_YEAR = log10((double)NUM_SECONDS_IN_ONE_YEAR);
+  static double LOG_YEAR = log10((double)s->txn_conf->cache_guaranteed_max_lifetime);
   const uint32_t granularity = 1000;
   int result = 0;
 
@@ -7308,7 +7308,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request,
HTTP
   if (s->txn_conf->freshness_fuzz_time >= 0) {
     fresh_limit = fresh_limit - calculate_freshness_fuzz(s, fresh_limit);
     fresh_limit = max(0, fresh_limit);
-    fresh_limit = min(NUM_SECONDS_IN_ONE_YEAR, fresh_limit);
+    fresh_limit = min((int)s->txn_conf->cache_guaranteed_max_lifetime, fresh_limit);
   }
 
   current_age = HttpTransactHeaders::calculate_document_age(s->request_sent_time, s->response_received_time,
cached_obj_response,
@@ -7316,9 +7316,9 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request,
HTTP
 
   // Overflow ?
   if (current_age < 0)
-    current_age = NUM_SECONDS_IN_ONE_YEAR; // TODO: Should we make a new "max age" define?
+    current_age = s->txn_conf->cache_guaranteed_max_lifetime;
   else
-    current_age = min((time_t)NUM_SECONDS_IN_ONE_YEAR, current_age);
+    current_age = min((time_t)s->txn_conf->cache_guaranteed_max_lifetime, current_age);
 
   DebugTxn("http_match", "[what_is_document_freshness] fresh_limit:  %d  current_age: %"
PRId64, fresh_limit, (int64_t)current_age);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bdca37f0/proxy/http/HttpTransact.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index e27616c..fa64940 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -46,7 +46,6 @@
 #include "congest/Congestion.h"
 
 #define MAX_DNS_LOOKUPS 2
-#define NUM_SECONDS_IN_ONE_YEAR (31536000) // (365L * 24L * 3600L)
 
 #define HTTP_RELEASE_ASSERT(X) ink_release_assert(X)
 // #define ink_cluster_time(X) time(X)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bdca37f0/proxy/http/HttpTransactCache.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransactCache.cc b/proxy/http/HttpTransactCache.cc
index 7b3eebc..66a9583 100644
--- a/proxy/http/HttpTransactCache.cc
+++ b/proxy/http/HttpTransactCache.cc
@@ -168,7 +168,7 @@ int
 HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector *cache_vector, HTTPHdr *client_request,
                                         CacheLookupHttpConfig *http_config_params)
 {
-  time_t current_age, best_age = NUM_SECONDS_IN_ONE_YEAR;
+  time_t current_age, best_age = CacheHighAgeWatermark;
   time_t t_now = 0;
   int best_index = -1;
   float best_Q = -1.0;
@@ -218,8 +218,9 @@ HttpTransactCache::SelectFromAlternates(CacheHTTPInfoVector *cache_vector,
HTTPH
         current_age = HttpTransactHeaders::calculate_document_age(obj->request_sent_time_get(),
obj->response_received_time_get(),
                                                                   cached_response, cached_response->get_date(),
t_now);
         // Overflow?
-        if (current_age < 0)
-          current_age = NUM_SECONDS_IN_ONE_YEAR; // TODO: Should we make a different define
for "max cache age" ?
+        if (current_age < 0) {
+          current_age = CacheHighAgeWatermark;
+        }
       } else {
         current_age = (time_t)0;
       }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bdca37f0/proxy/http/HttpTransactCache.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransactCache.h b/proxy/http/HttpTransactCache.h
index 610f012..bc3b680 100644
--- a/proxy/http/HttpTransactCache.h
+++ b/proxy/http/HttpTransactCache.h
@@ -33,6 +33,10 @@
 
 #include "libts.h"
 
+// This is needed since txn_conf->cache_guaranteed_max_lifetime is currently not
+// readily available in the cache. ToDo: We should fix this with TS-1919
+static const time_t CacheHighAgeWatermark = UINT_MAX;
+
 struct CacheHTTPInfoVector;
 
 class CacheLookupHttpConfig


Mime
View raw message