]> 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>
Sat, 21 Jun 2014 04:21:13 +0000 (22:21 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 21 Jun 2014 04:21:13 +0000 (22:21 -0600)
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 c558666812c8c3295b8e55cc0f4ece31303d9feb..64211919b4932bfbb5190b79fccb3a8f2ce9f18c 100644 (file)
@@ -143,6 +143,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()));
 
@@ -188,7 +192,7 @@ template <class EntryValue, size_t EntryCost>
 void
 LruMap<EntryValue, EntryCost>::trim()
 {
-    while (memLimit() > 0 && size() >= memLimit()) {
+    while (size() >= memLimit()) {
         QueueIterator i = index.end();
         --i;
         if (i != index.end()) {