]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Do not become a store_client for entries that are not backed by Store.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 1 Jul 2013 19:59:32 +0000 (13:59 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 1 Jul 2013 19:59:32 +0000 (13:59 -0600)
If we ignore cache backing when becoming a store client, then
StoreEntry::storeClientType() is going to make us a DISK_CLIENT by default.
If there is no disk cache or it cannot be used for our entry, we will assert
in store_client constructor. Prevent those assertions by checking earlier in
StoreEntry::validToSend().

src/store.cc

index d32f7c0eded26f05906a41694741ed4e148feac9..4e37a8f639e56ad11215624cd7cea0a97f0404b9 100644 (file)
@@ -1475,6 +1475,25 @@ StoreEntry::validToSend() const
     if (EBIT_TEST(flags, ENTRY_ABORTED))
         return 0;
 
+    // now check that the entry has a cache backing or is collapsed
+    if (swap_filen > -1) // backed by a disk cache
+        return 1;
+
+    if (swappingOut()) // will be backed by a disk cache
+        return 1;
+
+    if (!mem_obj) // not backed by a memory cache and not collapsed
+        return 0;
+
+    if (mem_obj->memCache.index >= 0) // backed by a shared memory cache
+        return 0;
+
+    // StoreEntry::storeClientType() assumes DISK_CLIENT here, but there is no
+    // disk cache backing so we should not rely on the store cache at all. This
+    // is wrong for range requests that could feed off nibbled memory (XXX).
+    if (mem_obj->inmem_lo) // in local memory cache, but got nibbled at
+        return 0;
+
     return 1;
 }