From: wessels <> Date: Wed, 15 Jul 1998 03:25:51 +0000 (+0000) Subject: StoreEntry->refresh was a bad idea. It would require changing X-Git-Tag: SQUID_3_0_PRE1~3093 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b5133db4955fcc7458754271e9f902a1fdb451c;p=thirdparty%2Fsquid.git StoreEntry->refresh was a bad idea. It would require changing swap.state format and would change the format depending on if USE_CACHE_DIGESTS were defined. Now we use default refresh_pattern entries if the StoreEntry doesn't have a MemObject (and therefore a URL). --- diff --git a/src/refresh.cc b/src/refresh.cc index 8a00b52030..f1cefc3b60 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -1,6 +1,6 @@ /* - * $Id: refresh.cc,v 1.21 1998/07/14 19:56:39 wessels Exp $ + * $Id: refresh.cc,v 1.22 1998/07/14 21:25:51 wessels Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -45,6 +45,9 @@ #define REFRESH_DEFAULT_PCT 0.20 #define REFRESH_DEFAULT_MAX (time_t)259200 +static const refresh_t * refreshLimits(const char *); +static const refresh_t *refreshUncompiledPattern(const char *); + static const refresh_t * refreshLimits(const char *url) { @@ -56,6 +59,17 @@ refreshLimits(const char *url) return NULL; } +static const refresh_t * +refreshUncompiledPattern(const char *pat) +{ + const refresh_t *R; + for (R = Config.Refresh; R; R = R->next) { + if (0 == strcmp(R->pattern, pat)) + return R; + } + return NULL; +} + /* * refreshCheck(): * return 1 if its time to revalidate this entry, 0 otherwise @@ -141,17 +155,21 @@ refreshWhen(const StoreEntry * entry) time_t max = REFRESH_DEFAULT_MAX; double pct = REFRESH_DEFAULT_PCT; const char *pattern = "."; - assert(entry->mem_obj); - assert(entry->mem_obj->url); - debug(22, 3) ("refreshWhen: key '%s'\n", storeKeyText(entry->key)); - debug(22, 3) ("refreshWhen: url '%s'\n", entry->mem_obj->url); - if (EBIT_TEST(entry->flag, ENTRY_REVALIDATE)) { - debug(22, 3) ("refreshWhen: NOW: Required Authorization\n"); - return refresh_time; + if (entry->mem_obj) { + assert(entry->mem_obj->url); + debug(22, 3) ("refreshWhen: key '%s'\n", storeKeyText(entry->key)); + debug(22, 3) ("refreshWhen: url '%s'\n", entry->mem_obj->url); + if (EBIT_TEST(entry->flag, ENTRY_REVALIDATE)) { + debug(22, 3) ("refreshWhen: NOW: Required Authorization\n"); + return refresh_time; + } + debug(22, 3) ("refreshWhen: entry: exp: %d, tstamp: %d, lmt: %d\n", + entry->expires, entry->timestamp, entry->lastmod); + R = refreshLimits(entry->mem_obj->url); + } else { + R = refreshUncompiledPattern("."); } - debug(22, 3) ("refreshWhen: entry: exp: %d, tstamp: %d, lmt: %d\n", - entry->expires, entry->timestamp, entry->lastmod); - if ((R = refreshLimits(entry->mem_obj->url))) { + if (R != NULL) { min = R->min; max = R->max; pct = R->pct; diff --git a/src/store.cc b/src/store.cc index 2115b40195..e5a575cc01 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.426 1998/07/14 20:54:54 wessels Exp $ + * $Id: store.cc,v 1.427 1998/07/14 21:25:53 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -988,9 +988,6 @@ storeTimestampsSet(StoreEntry * entry) if (entry->lastmod < 0) entry->lastmod = served_date; entry->timestamp = served_date; -#if USE_CACHE_DIGESTS - entry->refresh = refreshWhen(entry); -#endif } void diff --git a/src/store_digest.cc b/src/store_digest.cc index e50b3a453c..37e792308f 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,5 +1,5 @@ /* - * $Id: store_digest.cc,v 1.21 1998/07/14 20:54:56 wessels Exp $ + * $Id: store_digest.cc,v 1.22 1998/07/14 21:25:54 wessels Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -185,11 +185,12 @@ storeDigestAdd(const StoreEntry * entry) storeKeyText(entry->key)); /* only public entries are digested */ if (!EBIT_TEST(entry->flag, KEY_PRIVATE)) { + const time_t refresh = refreshWhen(entry); debug(71, 6) ("storeDigestAdd: entry expires in %d secs\n", - (int) (entry->refresh - squid_curtime)); + (int) (refresh - squid_curtime)); /* if expires too soon, ignore */ /* Note: We should use the time of the next rebuild, not cur_time @?@ */ - if (entry->refresh <= squid_curtime + StoreDigestRebuildPeriod) { + if (refresh <= squid_curtime + StoreDigestRebuildPeriod) { debug(71, 6) ("storeDigestAdd: entry expires too early, ignoring\n"); } else { good_entry = 1; diff --git a/src/structs.h b/src/structs.h index c9461c47cb..3cea6a859c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1093,9 +1093,6 @@ struct _StoreEntry { time_t lastref; time_t expires; time_t lastmod; -#if USE_CACHE_DIGESTS - time_t refresh; -#endif size_t swap_file_sz; u_short refcount; u_short flag;