]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Assure that when LruMap::memLimit_ is set to 0 no entries stored on LruMap
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Mon, 16 Jun 2014 16:16:10 +0000 (19:16 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Mon, 16 Jun 2014 16:16:10 +0000 (19:16 +0300)
Changes:
 - Do not add new entries to LruMap if memLimit is 0
 - Remove all entries in LruMap::trim if memLimit set to 0

src/base/LruMap.h

index c68a4fe02d5903ea99ee82016d82cabfdbadb9d5..c3ca9f784b9b66b0fe03e3be5b2589c337d30060 100644 (file)
@@ -140,6 +140,10 @@ LruMap<EntryValue, EntryCost>::add(const char *key, EntryValue *t)
 
     del(key);
     trim();
+
+    if (memLimit() == 0)
+        return false;
+
     index.push_front(new Entry(key, t));
     storage.insert(MapPair(key, index.begin()));
 
@@ -185,7 +189,7 @@ template <class EntryValue, size_t EntryCost>
 void
 LruMap<EntryValue, EntryCost>::trim()
 {
-    while (memLimit() > 0 && size() >= memLimit()) {
+    while (memLimit() >= 0 && size() >= memLimit()) {
         QueueIterator i = index.end();
         --i;
         if (i != index.end()) {