#endif
if (!shutting_down) { // Store::Root() is FATALly missing during shutdown
- // TODO: Consider moving these to destroyMemoryObject
- if (xitTable.index >= 0)
- Store::Root().transientsDisconnect(*this);
- if (memCache.index >= 0)
- Store::Root().memoryDisconnect(*this);
-
assert(xitTable.index < 0);
assert(memCache.index < 0);
assert(swapout.sio == NULL);
// would be nice to call validLength() here, but it needs e.key
// we read the entire response into the local memory; no more need to lock
- disconnect(*e.mem_obj);
+ disconnect(e);
return true;
}
if (!shouldCache(e) || !startCaching(e)) {
e.mem_obj->memCache.io = MemObject::ioDone;
Store::Root().transientsAbandon(e);
- CollapsedForwarding::Broadcast(e);
return;
}
break;
// fall through to the error handling code
}
- Store::Root().transientsAbandon(e);
- disconnect(*e.mem_obj);
- CollapsedForwarding::Broadcast(e);
+ disconnect(e);
}
void
assert(e.mem_obj);
if (e.mem_obj->memCache.index >= 0) {
map->freeEntry(e.mem_obj->memCache.index);
- disconnect(*e.mem_obj);
+ disconnect(e);
} else {
- // the entry may bave been loaded and then disconnected from the cache
+ // the entry may have been loaded and then disconnected from the cache
map->freeEntryByKey(reinterpret_cast<cache_key*>(e.key));
}
}
void
-MemStore::disconnect(MemObject &mem_obj)
+MemStore::disconnect(StoreEntry &e)
{
+ assert(e.mem_obj);
+ MemObject &mem_obj = *e.mem_obj;
if (mem_obj.memCache.index >= 0) {
if (mem_obj.memCache.io == MemObject::ioWriting) {
map->abortWriting(mem_obj.memCache.index);
+ mem_obj.memCache.index = -1;
+ mem_obj.memCache.io = MemObject::ioDone;
+ Store::Root().transientsAbandon(e); // broadcasts after the change
} else {
assert(mem_obj.memCache.io == MemObject::ioReading);
map->closeForReading(mem_obj.memCache.index);
+ mem_obj.memCache.index = -1;
+ mem_obj.memCache.io = MemObject::ioDone;
}
- mem_obj.memCache.index = -1;
- mem_obj.memCache.io = MemObject::ioDone;
}
}
void unlink(StoreEntry &e);
/// called when the entry is about to forget its association with mem cache
- void disconnect(MemObject &mem_obj);
+ void disconnect(StoreEntry &e);
/* Store API */
virtual int callback();
// XXX: This method belongs to Store::Root/StoreController, but it is here
// to avoid casting Root() to StoreController until Root() API is fixed.
/// disassociates the entry from the memory cache, preserving cached data
- virtual void memoryDisconnect(MemObject &mem_obj) {}
+ virtual void memoryDisconnect(StoreEntry &e) {}
/// If the entry is not found, return false. Otherwise, return true after
/// tying the entry to this cache and setting inSync to updateCollapsed().
virtual void transientsDisconnect(MemObject &mem_obj);
virtual void memoryOut(StoreEntry &e, const bool preserveSwappable);
virtual void memoryUnlink(StoreEntry &e);
- virtual void memoryDisconnect(MemObject &mem_obj);
+ virtual void memoryDisconnect(StoreEntry &e);
virtual void allowCollapsing(StoreEntry *e, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod);
virtual void syncCollapsed(const sfileno xitIndex);
StoreEntry::destroyMemObject()
{
debugs(20, 3, HERE << "destroyMemObject " << mem_obj);
- setMemStatus(NOT_IN_MEMORY);
- MemObject *mem = mem_obj;
- mem_obj = NULL;
- delete mem;
+
+ if (MemObject *mem = mem_obj) {
+ // Store::Root() is FATALly missing during shutdown
+ if (mem->xitTable.index >= 0 && !shutting_down)
+ Store::Root().transientsDisconnect(*mem);
+ if (mem->memCache.index >= 0 && !shutting_down)
+ Store::Root().memoryDisconnect(*this);
+
+ setMemStatus(NOT_IN_MEMORY);
+ mem_obj = NULL;
+ delete mem;
+ }
}
void
}
void
-StoreController::memoryDisconnect(MemObject &mem_obj)
+StoreController::memoryDisconnect(StoreEntry &e)
{
if (memStore)
- memStore->disconnect(mem_obj);
+ memStore->disconnect(e);
// else nothing to do for non-shared memory cache
}