]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Changed refresh_t->pct from an int to a double
authorwessels <>
Thu, 21 May 1998 09:59:34 +0000 (09:59 +0000)
committerwessels <>
Thu, 21 May 1998 09:59:34 +0000 (09:59 +0000)
src/cache_cf.cc
src/refresh.cc
src/structs.h

index 6c0f4731de227cfd485b93bc59c0adef7365b191..cd483d7fd2b38eb28fe757487939f1e1658a22ce 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -1075,9 +1075,13 @@ static void
 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;
     }
 }
@@ -1088,7 +1092,7 @@ parse_refreshpattern(refresh_t ** head)
     char *token;
     char *pattern;
     time_t min = 0;
-    int pct = 0;
+    double pct = 0.0;
     time_t max = 0;
     int i;
     refresh_t *t;
@@ -1110,7 +1114,7 @@ parse_refreshpattern(refresh_t ** head)
     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) {
@@ -1122,14 +1126,16 @@ parse_refreshpattern(refresh_t ** head)
            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;
index e0450dedb3694a58b5f85586f6e03077f117359d..344d172f9faedc39a84e8626e4a3d598caa27d06 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -42,7 +42,7 @@
  *      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 *
@@ -65,11 +65,11 @@ refreshCheck(const StoreEntry * entry, const request_t * request, time_t delta)
 {
     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)) {
@@ -83,7 +83,7 @@ refreshCheck(const StoreEntry * entry, const request_t * request, time_t delta)
        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) {
@@ -118,8 +118,8 @@ refreshCheck(const StoreEntry * entry, const request_t * request, time_t delta)
            (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;
@@ -135,7 +135,7 @@ refreshWhen(const StoreEntry * entry)
     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);
@@ -154,7 +154,7 @@ refreshWhen(const StoreEntry * 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;
@@ -165,7 +165,7 @@ refreshWhen(const StoreEntry * entry)
        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 */
index 04ad0c5b7744d02a3eb02303bc541d5186e401dc..a28e90f744d3b3eba2aeffc8ed249e7ac9d3f855 100644 (file)
@@ -1130,9 +1130,12 @@ struct _refresh_t {
     char *pattern;
     regex_t compiled_pattern;
     time_t min;
-    int pct;
+    double pct;
     time_t max;
     refresh_t *next;
+    struct {
+       int icase:1;
+    } flags;
 };
 
 struct _CommWriteStateData {