void
MemObject::delayRead(DeferredRead const &aRead)
{
+#if USE_DELAY_POOLS
+ if (readAheadPolicyCanRead()) {
+ if (DelayId mostAllowedId = mostBytesAllowed()) {
+ mostAllowedId.delayRead(aRead);
+ return;
+ }
+ }
+#endif
deferredReads.delayRead(aRead);
}
return statusIfComplete();
}
-#if USE_DELAY_POOLS
static void
readDelayed(void *context, CommRead const &)
{
state->flags.do_next_read = true;
state->maybeReadVirginBody();
}
-#endif
void
HttpStateData::readReply(const CommIoCbParams &io)
CommIoCbParams rd(this); // will be expanded with ReadNow results
rd.conn = io.conn;
rd.size = entry->bytesWanted(Range<size_t>(0, inBuf.spaceSize()));
-#if USE_DELAY_POOLS
- if (rd.size < 1) {
- assert(entry->mem_obj);
- /* read ahead limit */
- /* Perhaps these two calls should both live in MemObject */
+ if (rd.size <= 0) {
+ assert(entry->mem_obj);
AsyncCall::Pointer nilCall;
- if (!entry->mem_obj->readAheadPolicyCanRead()) {
- entry->mem_obj->delayRead(DeferredRead(readDelayed, this, CommRead(io.conn, NULL, 0, nilCall)));
- return;
- }
-
- /* delay id limit */
- entry->mem_obj->mostBytesAllowed().delayRead(DeferredRead(readDelayed, this, CommRead(io.conn, NULL, 0, nilCall)));
+ entry->mem_obj->delayRead(DeferredRead(readDelayed, this, CommRead(io.conn, NULL, 0, nilCall)));
return;
}
-#endif
switch (Comm::ReadNow(rd, inBuf)) {
case Comm::INPROGRESS:
* ->deferRead (fd, buf, len, callback, DelayAwareRead, this)
*/
- if (amountToRead == 0) {
+ if (amountToRead <= 0) {
assert (mem_obj);
- /* read ahead limit */
- /* Perhaps these two calls should both live in MemObject */
-#if USE_DELAY_POOLS
- if (!mem_obj->readAheadPolicyCanRead()) {
-#endif
- mem_obj->delayRead(DeferredRead(DeferReader, this, CommRead(conn, buf, len, callback)));
- return;
-#if USE_DELAY_POOLS
- }
-
- /* delay id limit */
- mem_obj->mostBytesAllowed().delayRead(DeferredRead(DeferReader, this, CommRead(conn, buf, len, callback)));
+ mem_obj->delayRead(DeferredRead(DeferReader, this, CommRead(conn, buf, len, callback)));
return;
-
-#endif
-
}
if (fd_table[conn->fd].closing()) {
static void storeClientCopy2(StoreEntry * e, store_client * sc);
static EVH storeClientCopyEvent;
static bool CheckQuickAbortIsReasonable(StoreEntry * entry);
-static void CheckQuickAbort(StoreEntry * entry);
CBDATA_CLASS_INIT(store_client);
assert(e->locked());
// An entry locked by others may be unlocked (and destructed) by others, so
- // we must lock again to safely dereference e after CheckQuickAbort().
+ // we must lock again to safely dereference e after CheckQuickAbortIsReasonable().
e->lock("storeUnregister");
- if (mem->nclients == 0)
- CheckQuickAbort(e);
+ if (CheckQuickAbortIsReasonable(e))
+ e->abort();
else
mem->kickReads();
static bool
CheckQuickAbortIsReasonable(StoreEntry * entry)
{
+ assert(entry);
+ debugs(90, 3, "entry=" << *entry);
+
+ if (storePendingNClients(entry) > 0) {
+ debugs(90, 3, "quick-abort? NO storePendingNClients() > 0");
+ return false;
+ }
+
+ if (!shutting_down && Store::Root().transientReaders(*entry)) {
+ debugs(90, 3, "quick-abort? NO still have one or more transient readers");
+ return false;
+ }
+
+ if (entry->store_status != STORE_PENDING) {
+ debugs(90, 3, "quick-abort? NO store_status != STORE_PENDING");
+ return false;
+ }
+
+ if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) {
+ debugs(90, 3, "quick-abort? NO ENTRY_SPECIAL");
+ return false;
+ }
+
MemObject * const mem = entry->mem_obj;
assert(mem);
- debugs(90, 3, "entry=" << entry << ", mem=" << mem);
+ debugs(90, 3, "mem=" << mem);
if (mem->request && !mem->request->flags.cachable) {
debugs(90, 3, "quick-abort? YES !mem->request->flags.cachable");
return true;
}
-/// Aborts a swapping-out entry if nobody needs it any more _and_
-/// continuing swap out is not reasonable per CheckQuickAbortIsReasonable().
-static void
-CheckQuickAbort(StoreEntry * entry)
-{
- assert (entry);
-
- if (storePendingNClients(entry) > 0)
- return;
-
- if (!shutting_down && Store::Root().transientReaders(*entry))
- return;
-
- if (entry->store_status != STORE_PENDING)
- return;
-
- if (EBIT_TEST(entry->flags, ENTRY_SPECIAL))
- return;
-
- if (!CheckQuickAbortIsReasonable(entry))
- return;
-
- entry->abort();
-}
-
void
store_client::dumpStats(MemBuf * output, int clientNumber) const
{