]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Fri, 6 Oct 2000 11:12:35 +0000 (11:12 +0000)
committerwessels <>
Fri, 6 Oct 2000 11:12:35 +0000 (11:12 +0000)
 - In lru_remove(), it seems to be possible for an entry to exist
   in the hash but not be in the LRU list, so check for that case
   rather than suffer a NULL pointer access.

src/repl/lru/store_repl_lru.cc

index 2a6e82c1ac57446960a362a6e5b952a003254810..3f2859768fa6cb268aa247aef4ee66fbcf050831 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.1 2000/06/08 18:05:40 hno Exp $
+ * $Id: store_repl_lru.cc,v 1.2 2000/10/06 05:12:35 wessels Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -100,6 +100,13 @@ lru_remove(RemovalPolicy * policy, StoreEntry * entry, RemovalPolicyNode * node)
     LruNode *lru_node = node->data;
     if (!lru_node)
        return;
+    /*
+     * It seems to be possible for an entry to exist in the hash
+     * but not be in the LRU list, so check for that case rather
+     * than suffer a NULL pointer access.
+     */
+    if (NULL == lru_node->node.data)
+       return;
     assert(lru_node->node.data == entry);
     node->data = NULL;
     dlinkDelete(&lru_node->node, &lru->list);
@@ -286,73 +293,3 @@ createRemovalPolicy_lru(wordlist *args)
     return policy;
 }
 
-
-#if OLD_UNUSED_CODE
-/*
- * storeUfsDirCheckExpired
- *
- * Check whether the given object is expired or not
- * It breaks layering a little by calling the upper layers to find
- * out whether the object is locked or not, but we can't help this
- * right now.
- */
-static int
-storeUfsDirCheckExpired(SwapDir * SD, StoreEntry * e)
-{
-    if (storeEntryLocked(e))
-       return 0;
-    if (EBIT_TEST(e->flags, RELEASE_REQUEST))
-       return 1;
-    if (EBIT_TEST(e->flags, ENTRY_NEGCACHED) && squid_curtime >= e->expires)
-       return 1;
-
-#if HEAP_REPLACEMENT
-    /*
-     * with HEAP_REPLACEMENT we are not using the LRU reference age, the heap
-     * controls the replacement of objects.
-     */
-    return 1;
-#else
-    if (squid_curtime - e->lastref > storeUfsDirExpiredReferenceAge(SD))
-       return 1;
-    return 0;
-#endif
-}
-
-/*
- * storeUfsDirExpiredReferenceAge
- *
- * The LRU age is scaled exponentially between 1 minute and
- * Config.referenceAge , when store_swap_low < store_swap_size <
- * store_swap_high.  This keeps store_swap_size within the low and high
- * water marks.  If the cache is very busy then store_swap_size stays
- * closer to the low water mark, if it is not busy, then it will stay
- * near the high water mark.  The LRU age value can be examined on the
- * cachemgr 'info' page.
- */
-static time_t
-storeUfsDirExpiredReferenceAge(SwapDir * SD)
-{
-    double x;
-    double z;
-    time_t age;
-    long store_high, store_low;
-
-    store_high = (long) (((float) SD->max_size *
-           (float) Config.Swap.highWaterMark) / (float) 100);
-    store_low = (long) (((float) SD->max_size *
-           (float) Config.Swap.lowWaterMark) / (float) 100);
-    debug(81, 4) ("storeUfsDirExpiredReferenceAge: Dir %s, hi=%d, lo=%d, cur=%d\n", SD->path, store_high,
-       store_low, SD->cur_size);
-
-    x = (double) (store_high - SD->cur_size) / (store_high - store_low);
-    x = x < 0.0 ? 0.0 : x > 1.0 ? 1.0 : x;
-    z = pow((double) (Config.referenceAge / 60), x);
-    age = (time_t) (z * 60.0);
-    if (age < 60)
-       age = 60;
-    else if (age > Config.referenceAge)
-       age = Config.referenceAge;
-    return age;
-}
-#endif /* OLD_UNUSED_CODE */