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().
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;
}