]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added time_t StoreEntry->refresh for cache digests.
authorwessels <>
Wed, 15 Jul 1998 02:54:53 +0000 (02:54 +0000)
committerwessels <>
Wed, 15 Jul 1998 02:54:53 +0000 (02:54 +0000)
Don't need to compile a lot of the store_digest code when USE_CACHE_DIGESTS
is not set

src/protos.h
src/store.cc
src/store_digest.cc
src/structs.h

index 7c108ff3c5aa94da789f02adf399f36b60b8aa1d..33f950c0ffeccce18c5b69ac57e7a5c6e4fe5efb 100644 (file)
@@ -782,7 +782,6 @@ extern EVH storeDirClean;
 extern void storeDigestInit();
 extern void storeDigestNoteStoreReady();
 extern void storeDigestScheduleRebuild();
-extern void storeDigestAdd(const StoreEntry * entry);
 extern void storeDigestDel(const StoreEntry * entry);
 extern void storeDigestReport();
 
index 5df41faabfcba20b69c8b397a4ab37fe3ee06f4c..2115b4019581c2fecb3fd53b79cc05e6ccb66497 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.425 1998/07/07 02:54:17 wessels Exp $
+ * $Id: store.cc,v 1.426 1998/07/14 20:54:54 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -988,7 +988,9 @@ 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
index 2d41cb46ebf88814a6db49e6285ceac31c9a55c4..e50b3a453c7ca263b239275ac3c1e2c2fffa28be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: store_digest.cc,v 1.20 1998/06/05 22:37:45 rousskov Exp $
+ * $Id: store_digest.cc,v 1.21 1998/07/14 20:54:56 wessels Exp $
  *
  * DEBUG: section 71    Store Digest Manager
  * AUTHOR: Alex Rousskov
 
 #include "squid.h"
 
-/* local types */
+#if USE_CACHE_DIGESTS
+
+/*
+ * local types
+ */
 
 typedef struct {
     StoreDigestCBlock cblock;
@@ -79,44 +83,100 @@ static StoreDigestStats sd_stats;
 
 /* local prototypes */
 static void storeDigestRebuildStart(void *datanotused);
-static void storeDigestRebuildResume();
-static void storeDigestRebuildFinish();
+static void storeDigestRebuildResume(void);
+static void storeDigestRebuildFinish(void);
 static void storeDigestRebuildStep(void *datanotused);
-static void storeDigestRewriteStart();
-static void storeDigestRewriteResume();
+static void storeDigestRewriteStart(void *);
+static void storeDigestRewriteResume(void);
 static void storeDigestRewriteFinish(StoreEntry * e);
 static EVH storeDigestSwapOutStep;
 static void storeDigestCBlockSwapOut(StoreEntry * e);
-static int storeDigestCalcCap();
-static int storeDigestResize();
+static int storeDigestCalcCap(void);
+static int storeDigestResize(void);
+static void storeDigestAdd(const StoreEntry *);
 
+#endif /* USE_CACHE_DIGESTS */
+
+/*
+ * PUBLIC FUNCTIONS
+ */
 
 void
-storeDigestInit()
+storeDigestInit(void)
 {
 #if USE_CACHE_DIGESTS
     const int cap = storeDigestCalcCap();
     store_digest = cacheDigestCreate(cap, StoreDigestBitsPerEntry);
     debug(71, 1) ("Local cache digest enabled; rebuild/rewrite every %d/%d sec\n",
        StoreDigestRebuildPeriod, StoreDigestRewritePeriod);
-#else
-    store_digest = NULL;
-    debug(71, 1) ("Local cache digest is 'off'\n");
-#endif
     memset(&sd_state, 0, sizeof(sd_state));
     cachemgrRegister("store_digest", "Store Digest",
        storeDigestReport, 0);
+#else
+    store_digest = NULL;
+    debug(71, 3) ("Local cache digest is 'off'\n");
+#endif
 }
 
 /* called when store_rebuild completes */
 void
-storeDigestNoteStoreReady()
+storeDigestNoteStoreReady(void)
 {
+#if USE_CACHE_DIGESTS
     storeDigestRebuildStart(NULL);
     storeDigestRewriteStart(NULL);
+#endif
+}
+
+void
+storeDigestDel(const StoreEntry * entry)
+{
+#if USE_CACHE_DIGESTS
+    assert(entry && store_digest);
+    debug(71, 6) ("storeDigestDel: checking entry, key: %s\n",
+       storeKeyText(entry->key));
+    if (!EBIT_TEST(entry->flag, KEY_PRIVATE)) {
+       if (!cacheDigestTest(store_digest, entry->key)) {
+           sd_stats.del_lost_count++;
+           debug(71, 6) ("storeDigestDel: lost entry, key: %s url: %s\n",
+               storeKeyText(entry->key), storeUrl(entry));
+       } else {
+           sd_stats.del_count++;
+           cacheDigestDel(store_digest, entry->key);
+           debug(71, 6) ("storeDigestDel: deled entry, key: %s\n",
+               storeKeyText(entry->key));
+       }
+    }
+#endif
 }
 
 void
+storeDigestReport(StoreEntry * e)
+{
+#if USE_CACHE_DIGESTS
+    if (store_digest) {
+       cacheDigestReport(store_digest, "store", e);
+       storeAppendPrintf(e, "\t added: %d rejected: %d ( %.2f %%) del-ed: %d\n",
+           sd_stats.add_count,
+           sd_stats.rej_count,
+           xpercent(sd_stats.rej_count, sd_stats.rej_count + sd_stats.add_count),
+           sd_stats.del_count);
+       storeAppendPrintf(e, "\t collisions: on add: %.2f %% on rej: %.2f %%\n",
+           xpercent(sd_stats.add_coll_count, sd_stats.add_count),
+           xpercent(sd_stats.rej_coll_count, sd_stats.rej_count));
+    } else {
+       storeAppendPrintf(e, "store digest: disabled.\n");
+    }
+#endif
+}
+
+/*
+ * LOCAL FUNCTIONS
+ */
+
+#if USE_CACHE_DIGESTS
+
+static void
 storeDigestAdd(const StoreEntry * entry)
 {
     int good_entry = 0;
@@ -125,12 +185,11 @@ storeDigestAdd(const StoreEntry * entry)
        storeKeyText(entry->key));
     /* only public entries are digested */
     if (!EBIT_TEST(entry->flag, KEY_PRIVATE)) {
-       const time_t expires = refreshWhen(entry);
        debug(71, 6) ("storeDigestAdd: entry expires in %d secs\n",
-           (int) (expires - squid_curtime));
+           (int) (entry->refresh - squid_curtime));
        /* if expires too soon, ignore */
        /* Note: We should use the time of the next rebuild, not cur_time @?@ */
-       if (expires <= squid_curtime + StoreDigestRebuildPeriod) {
+       if (entry->refresh <= squid_curtime + StoreDigestRebuildPeriod) {
            debug(71, 6) ("storeDigestAdd: entry expires too early, ignoring\n");
        } else {
            good_entry = 1;
@@ -150,26 +209,6 @@ storeDigestAdd(const StoreEntry * entry)
     }
 }
 
-void
-storeDigestDel(const StoreEntry * entry)
-{
-    assert(entry && store_digest);
-    debug(71, 6) ("storeDigestDel: checking entry, key: %s\n",
-       storeKeyText(entry->key));
-    if (!EBIT_TEST(entry->flag, KEY_PRIVATE)) {
-       if (!cacheDigestTest(store_digest, entry->key)) {
-           sd_stats.del_lost_count++;
-           debug(71, 6) ("storeDigestDel: lost entry, key: %s url: %s\n",
-               storeKeyText(entry->key), storeUrl(entry));
-       } else {
-           sd_stats.del_count++;
-           cacheDigestDel(store_digest, entry->key);
-           debug(71, 6) ("storeDigestDel: deled entry, key: %s\n",
-               storeKeyText(entry->key));
-       }
-    }
-}
-
 /* rebuilds digest from scratch */
 static void
 storeDigestRebuildStart(void *datanotused)
@@ -191,7 +230,7 @@ storeDigestRebuildStart(void *datanotused)
 
 /* called be Rewrite to push Rebuild forward */
 static void
-storeDigestRebuildResume()
+storeDigestRebuildResume(void)
 {
     assert(sd_state.rebuild_lock);
     assert(!sd_state.rewrite_lock);
@@ -205,7 +244,7 @@ storeDigestRebuildResume()
 
 /* finishes swap out sequence for the digest; schedules next rebuild */
 static void
-storeDigestRebuildFinish()
+storeDigestRebuildFinish(void)
 {
     assert(sd_state.rebuild_lock);
     sd_state.rebuild_lock = 0;
@@ -275,7 +314,7 @@ storeDigestRewriteStart(void *datanotused)
 }
 
 static void
-storeDigestRewriteResume()
+storeDigestRewriteResume(void)
 {
     StoreEntry *e = sd_state.rewrite_lock;
 
@@ -363,7 +402,7 @@ storeDigestCBlockSwapOut(StoreEntry * e)
 
 /* calculates digest capacity */
 static int
-storeDigestCalcCap()
+storeDigestCalcCap(void)
 {
     /*
      * To-Do: Bloom proved that the optimal filter utilization is 50% (half of
@@ -387,7 +426,7 @@ storeDigestCalcCap()
 
 /* returns true if we actually resized the digest */
 static int
-storeDigestResize()
+storeDigestResize(void)
 {
     const int cap = storeDigestCalcCap();
     int diff;
@@ -407,20 +446,4 @@ storeDigestResize()
     }
 }
 
-void
-storeDigestReport(StoreEntry * e)
-{
-    if (store_digest) {
-       cacheDigestReport(store_digest, "store", e);
-       storeAppendPrintf(e, "\t added: %d rejected: %d ( %.2f %%) del-ed: %d\n",
-           sd_stats.add_count,
-           sd_stats.rej_count,
-           xpercent(sd_stats.rej_count, sd_stats.rej_count + sd_stats.add_count),
-           sd_stats.del_count);
-       storeAppendPrintf(e, "\t collisions: on add: %.2f %% on rej: %.2f %%\n",
-           xpercent(sd_stats.add_coll_count, sd_stats.add_count),
-           xpercent(sd_stats.rej_coll_count, sd_stats.rej_count));
-    } else {
-       storeAppendPrintf(e, "store digest: disabled.\n");
-    }
-}
+#endif /* USE_CACHE_DIGESTS */
index 3cea6a859c25cc4fb0c1c8cb9fbe5eb56433b243..c9461c47cb7d5d37c891a5140195717bc22d515a 100644 (file)
@@ -1093,6 +1093,9 @@ 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;