/*
- * $Id: cache_cf.cc,v 1.281 1998/05/01 21:09:55 wessels Exp $
+ * $Id: cache_cf.cc,v 1.282 1998/05/21 03:59:34 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
{
while (head != NULL) {
- storeAppendPrintf(entry, "%s %s %d %d%% %d\n",
- name, head->pattern,
- (int) head->min, head->pct, (int) head->max);
+ storeAppendPrintf(entry, "%s%s %s %d %d%% %d\n",
+ name,
+ head->flags.icase ? " -i" : null_string,
+ head->pattern,
+ (int) head->min / 60,
+ (int) (100.0 * head->pct + 0.5),
+ (int) head->max / 60);
head = head->next;
}
}
char *token;
char *pattern;
time_t min = 0;
- int pct = 0;
+ double pct = 0.0;
time_t max = 0;
int i;
refresh_t *t;
GetInteger(i); /* token: min */
min = (time_t) (i * 60); /* convert minutes to seconds */
GetInteger(i); /* token: pct */
- pct = i;
+ pct = (double) i / 100.0;
GetInteger(i); /* token: max */
max = (time_t) (i * 60); /* convert minutes to seconds */
if ((errcode = regcomp(&comp, pattern, flags)) != 0) {
pattern, errbuf);
return;
}
- pct = pct < 0 ? 0 : pct;
+ pct = pct < 0.0 ? 0.0 : pct;
max = max < 0 ? 0 : max;
t = xcalloc(1, sizeof(refresh_t));
t->pattern = (char *) xstrdup(pattern);
t->compiled_pattern = comp;
t->min = min;
- t->pct = pct * QUICK_ABORT_100PCT / 100;
+ t->pct = pct;
t->max = max;
+ if (flags & REG_ICASE)
+ t->flags.icase = 1;
t->next = NULL;
while (*head)
head = &(*head)->next;
/*
- * $Id: refresh.cc,v 1.19 1998/04/24 07:09:44 wessels Exp $
+ * $Id: refresh.cc,v 1.20 1998/05/21 03:59:35 wessels Exp $
*
* DEBUG: section 22 Refresh Calculation
* AUTHOR: Harvest Derived
* MAX 3 days
*/
#define REFRESH_DEFAULT_MIN (time_t)0
-#define REFRESH_DEFAULT_PCT (time_t)20
+#define REFRESH_DEFAULT_PCT 0.20
#define REFRESH_DEFAULT_MAX (time_t)259200
static const refresh_t *
{
const refresh_t *R;
time_t min = REFRESH_DEFAULT_MIN;
- int pct = REFRESH_DEFAULT_PCT;
+ double pct = REFRESH_DEFAULT_PCT;
time_t max = REFRESH_DEFAULT_MAX;
const char *pattern = ".";
time_t age;
- int factor;
+ double factor;
time_t check_time = squid_curtime + delta;
debug(22, 3) ("refreshCheck: '%s'\n", storeUrl(entry));
if (EBIT_TEST(entry->flag, ENTRY_REVALIDATE)) {
pattern = R->pattern;
}
debug(22, 3) ("refreshCheck: Matched '%s %d %d%% %d'\n",
- pattern, (int) min, pct, (int) max);
+ pattern, (int) min, (int) (100.0 * pct), (int) max);
age = check_time - entry->timestamp;
debug(22, 3) ("refreshCheck: age = %d\n", (int) age);
if (request->max_age > -1) {
(int) entry->timestamp, (int) entry->lastmod);
return 1;
}
- factor = 100 * age / (entry->timestamp - entry->lastmod);
- debug(22, 3) ("refreshCheck: factor = %d\n", factor);
+ factor = (double) age / (double) (entry->timestamp - entry->lastmod);
+ debug(22, 3) ("refreshCheck: factor = %f\n", factor);
if (factor < pct) {
debug(22, 3) ("refreshCheck: NO: factor < pct\n");
return 0;
time_t refresh_time = squid_curtime;
time_t min = REFRESH_DEFAULT_MIN;
time_t max = REFRESH_DEFAULT_MAX;
- int pct = REFRESH_DEFAULT_PCT;
+ double pct = REFRESH_DEFAULT_PCT;
const char *pattern = ".";
assert(entry);
pattern = R->pattern;
}
debug(22, 3) ("refreshWhen: Matched '%s %d %d%% %d'\n",
- pattern, (int) min, pct, (int) max);
+ pattern, (int) min, (int) (100.0 * pct), (int) max);
/* convert to absolute numbers */
min += entry->timestamp;
max += entry->timestamp;
debug(22, 3) ("refreshWhen: lastvalid <= lastmod\n");
refresh_time = squid_curtime;
} else {
- refresh_time = pct * (entry->timestamp - entry->lastmod) / 100 + entry->timestamp;
+ refresh_time = (entry->timestamp - entry->lastmod) * pct + entry->timestamp;
debug(22, 3) ("refreshWhen: using refresh pct\n");
}
/* take min/max into account, max takes priority over min */