Hello,
Here's my patch enabling different time definitions for
refresh_patterns for both 2.5-STABLE4 and yesterday's CVS
HEAD of 3.0. I noticed now there's a patch to define the
refresh_patterns in fractions, however I think I prefer
my patch more :)
I'm not sure if these are coded according to Squid's standards,
but here they are anyway. Supported time syntaxes are s,
m, h and d (eg. 30s, 5m, 1h, 7d). If no qualifier
is specified, it defaults to minutes.
The patches include a patch for refreshIsCacheable, that drops
the lower limit for cacheability to 1 second. This is something
that may not be good - I'm not sure. Maybe a safer way would
be to set the lower limit to the lowest defined refresh_pattern
min age.
--
Taneli Leppä | Crasman Co Ltd
[EMAIL PROTECTED] | http://www.crasman.fi/
--- squid-2.5.STABLE4/src/refresh.c 2002-07-18 12:22:17.0 +0300
+++ squid-2.5.STABLE4-refresh/src/refresh.c 2004-02-18 11:54:21.0 +0200
@@ -331,7 +331,7 @@
* 60 seconds delta, to avoid objects which expire almost
* immediately, and which can't be refreshed.
*/
-int reason = refreshCheck(entry, NULL, 60);
+int reason = refreshCheck(entry, NULL, 1);
refreshCounts[rcStore].total++;
refreshCounts[rcStore].status[reason]++;
if (reason 200)
--- squid-2.5.STABLE4/src/cache_cf.c2003-07-01 23:42:41.0 +0300
+++ squid-2.5.STABLE4-refresh/src/cache_cf.c2004-02-18 12:54:10.0 +0200
@@ -218,6 +218,36 @@
return i;
}
+int
+GetTimeAsSeconds(void)
+{
+char *token = strtok(NULL, w_space);
+char tdef[2] = { 0 };
+int i;
+
+if (token == NULL)
+ self_destruct();
+if (sscanf(token, %d%1s, i, tdef) 1)
+ self_destruct();
+
+/* Check if a time format definition was given.
+ Supported types:
+ s = seconds
+ m = minutes
+ h = hours
+ d = days
+*/
+if (strcmp(tdef, ) == 0 || strcmp(tdef, m) == 0) {
+ i = i * 60;
+} else if (strcmp(tdef, h) == 0) {
+ i = i * 3600;
+} else if (strcmp(tdef, d) == 0) {
+ i = i * 86400;
+}
+return i;
+}
+
+
static void
update_maxobjsize(void)
{
@@ -1779,13 +1809,13 @@
dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
{
while (head != NULL) {
- storeAppendPrintf(entry, %s%s %s %d %d%% %d\n,
+ storeAppendPrintf(entry, %s%s %s %ds %d%% %ds\n,
name,
head-flags.icase ? -i : null_string,
head-pattern,
- (int) head-min / 60,
+ (int) head-min,
(int) (100.0 * head-pct + 0.5),
- (int) head-max / 60);
+ (int) head-max);
#if HTTP_VIOLATIONS
if (head-flags.override_expire)
storeAppendPrintf(entry, override-expire);
@@ -1832,12 +1862,11 @@
if (token == NULL)
self_destruct();
pattern = xstrdup(token);
-i = GetInteger(); /* token: min */
-min = (time_t) (i * 60); /* convert minutes to seconds */
-i = GetInteger(); /* token: pct */
+min = (time_t) GetTimeAsSeconds(); /* token: min */
+i = GetInteger(); /* token: pct */
pct = (double) i / 100.0;
-i = GetInteger(); /* token: max */
-max = (time_t) (i * 60); /* convert minutes to seconds */
+max = (time_t) GetTimeAsSeconds(); /* token: max */
+
/* Options */
while ((token = strtok(NULL, w_space)) != NULL) {
#if HTTP_VIOLATIONS
--- squid-3.0-PRE3-20040218/src/refresh.cc 2003-08-10 14:00:44.0 +0300
+++ squid-3.0-PRE3-20040218-refresh/src/refresh.cc 2004-02-18 13:01:31.0
+0200
@@ -398,7 +398,7 @@
* refreshed, but the expiry may be low to enforce regular
* checks
*/
-int reason = refreshCheck(entry, NULL, ESI ? 0 : 60);
+int reason = refreshCheck(entry, NULL, ESI ? 0 : 1);
refreshCounts[rcStore].total++;
refreshCounts[rcStore].status[reason]++;
--- squid-3.0-PRE3-20040218/src/cache_cf.cc 2003-11-06 18:55:24.0 +0200
+++ squid-3.0-PRE3-20040218-refresh/src/cache_cf.cc 2004-02-18 13:08:32.0
+0200
@@ -256,6 +256,36 @@
return i;
}
+int
+GetTimeAsSeconds(void)
+{
+char *token = strtok(NULL, w_space);
+char tdef[2] = { 0 };
+int i;
+
+if (token == NULL)
+ self_destruct();
+if (sscanf(token, %d%1s, i, (char *)tdef) 1)
+ self_destruct();
+
+/* Check if a time format definition was given.
+ Supported types:
+ s = seconds
+ m = minutes
+ h = hours
+ d = days
+*/
+if (strcmp(tdef, ) == 0 || strcmp(tdef, m) == 0) {
+ i = i * 60;
+} else if (strcmp(tdef, h) == 0) {
+ i = i * 3600;
+} else if (strcmp(tdef, d) == 0) {
+ i = i * 86400;
+}
+return i;
+}
+
+
static void
update_maxobjsize(void)
{
@@ -2024,13 +2054,13 @@
dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
{
while (head != NULL