static DeferredRead::DeferrableRead DeferReader;
bool checkDeferRead(int fd) const;
- virtual const char *getMD5Text() const;
+ const char *getMD5Text() const;
StoreEntry();
virtual ~StoreEntry();
- virtual HttpReply const *getReply() const;
- virtual void write (StoreIOBuffer);
+ HttpReply const *getReply() const;
+ void write(StoreIOBuffer);
- /** Check if the Store entry is emtpty
+ /** Check if the Store entry is empty
* \retval true Store contains 0 bytes of data.
* \retval false Store contains 1 or more bytes of data.
* \retval false Store contains negative content !!!!!!
*/
- virtual bool isEmpty() const {
+ bool isEmpty() const {
assert (mem_obj);
return mem_obj->endOffset() == 0;
}
- virtual bool isAccepting() const;
- virtual size_t bytesWanted(Range<size_t> const aRange, bool ignoreDelayPool = false) const;
+ bool isAccepting() const;
+ size_t bytesWanted(Range<size_t> const aRange, bool ignoreDelayPool = false) const;
/// flags [truncated or too big] entry with ENTRY_BAD_LENGTH and releases it
void lengthWentBad(const char *reason);
- virtual void complete();
- virtual store_client_t storeClientType() const;
- virtual char const *getSerialisedMetaData();
+ void complete();
+ store_client_t storeClientType() const;
+ char const *getSerialisedMetaData();
/// Store a prepared error response. MemObject locks the reply object.
void storeErrorResponse(HttpReply *reply);
void replaceHttpReply(HttpReply *, bool andStartWriting = true);
void startWriting(); ///< pack and write reply headers and, maybe, body
/// whether we may start writing to disk (now or in the future)
- virtual bool mayStartSwapOut();
- virtual void trimMemory(const bool preserveSwappable);
+ bool mayStartSwapOut();
+ void trimMemory(const bool preserveSwappable);
// called when a decision to cache in memory has been made
void memOutDecision(const bool willCacheInRam);
static void getPublicByRequest(StoreClient * aClient, HttpRequest * request);
static void getPublic(StoreClient * aClient, const char *uri, const HttpRequestMethod& method);
- virtual bool isNull() const { return false; } // TODO: Replace with nullptr.
-
void *operator new(size_t byteCount);
void operator delete(void *address);
#if USE_SQUID_ESI
ESIElement::Pointer cachedESITree;
#endif
- virtual int64_t objectLen() const;
- virtual int64_t contentLen() const;
+ int64_t objectLen() const;
+ int64_t contentLen() const;
/// claim shared ownership of this entry (for use in a given context)
/// matching lock() and unlock() contexts eases leak triage but is optional
/// Removes all unlocked (and marks for eventual removal all locked) Store
/// entries, including attached and unattached entries that have our key.
/// Also destroys us if we are unlocked or makes us private otherwise.
- /// TODO: remove virtual.
- virtual void release(const bool shareable = false);
+ void release(const bool shareable = false);
/// One of the three methods to get rid of an unlocked StoreEntry object.
/// May destroy this object if it is unlocked; does nothing otherwise.
std::ostream &operator <<(std::ostream &os, const StoreEntry &e);
-/// \ingroup StoreAPI
-class NullStoreEntry:public StoreEntry
-{
-
-public:
- static NullStoreEntry *getInstance();
-
- const char *getMD5Text() const;
- HttpReply const *getReply() const { return NULL; }
- void write (StoreIOBuffer) {}
-
- bool isEmpty () const {return true;}
-
- /* StoreEntry API */
- virtual bool isNull() const { return true; }
- virtual size_t bytesWanted(Range<size_t> const aRange, bool) const { return aRange.end; }
-
- void operator delete(void *address);
- void complete() {}
-
-private:
- store_client_t storeClientType() const {return STORE_MEM_CLIENT;}
-
- char const *getSerialisedMetaData();
- virtual bool mayStartSwapOut() { return false; }
-
- void trimMemory(const bool) {}
-
- static NullStoreEntry _instance;
-};
-
/// \ingroup StoreAPI
typedef void (*STOREGETCLIENT) (StoreEntry *, void *cbdata);
// TODO: Remove? Probably added to make lookups asynchronous, but they are
// still blocking. A lot more is needed to support async callbacks.
/// Handle a StoreEntry::getPublic*() result.
- /// An isNull() entry indicates a cache miss.
+ /// A nil entry indicates a cache miss.
virtual void created(StoreEntry *) = 0;
/// \return LogTags (if the class logs transactions) or nil (otherwise)
void
clientReplyContext::purgeFoundGet(StoreEntry *newEntry)
{
- if (newEntry->isNull()) {
+ if (!newEntry) {
lookingforstore = 2;
StoreEntry::getPublicByRequestMethod(this, http->request, Http::METHOD_HEAD);
} else
void
clientReplyContext::purgeFoundHead(StoreEntry *newEntry)
{
- if (newEntry->isNull())
+ if (!newEntry)
purgeDoMissPurge();
else
purgeFoundObject (newEntry);
void
clientReplyContext::purgeFoundObject(StoreEntry *entry)
{
- assert (entry && !entry->isNull());
+ assert (entry);
if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) {
http->logType.update(LOG_TCP_DENIED);
void
clientReplyContext::purgeDoPurgeGet(StoreEntry *newEntry)
{
- assert (newEntry);
- /* Move to new() when that is created */
- purgeStatus = Http::scNotFound;
-
- if (!newEntry->isNull()) {
+ if (newEntry) {
+ /* Move to new() when that is created */
+ purgeStatus = Http::scNotFound;
/* Release the cached URI */
debugs(88, 4, "clientPurgeRequest: GET '" << newEntry->url() << "'" );
#if USE_HTCP
void
clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry)
{
- if (newEntry && !newEntry->isNull()) {
+ if (newEntry) {
debugs(88, 4, "HEAD " << newEntry->url());
#if USE_HTCP
neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(Http::METHOD_HEAD), HTCP_CLR_PURGE);
lookingforstore = 5;
StoreEntry::getPublicByRequest (this, r);
} else {
- identifyFoundObject (NullStoreEntry::getInstance());
+ identifyFoundObject(nullptr);
}
}
void
clientReplyContext::identifyFoundObject(StoreEntry *newEntry)
{
- StoreEntry *e = newEntry;
HttpRequest *r = http->request;
-
- /** \li If the entry received isNull() then we ignore it. */
- if (e->isNull()) {
- http->storeEntry(NULL);
- } else {
- http->storeEntry(e);
- }
-
- e = http->storeEntry();
+ http->storeEntry(newEntry);
+ const auto e = http->storeEntry();
/* Release IP-cache entries on reload */
/** \li If the request has no-cache flag set or some no_cache HACK in operation we
ipcacheInvalidateNegative(r->url.host());
#if USE_CACHE_DIGESTS
- lookup_type = http->storeEntry() ? "HIT" : "MISS";
+ lookup_type = e ? "HIT" : "MISS";
#endif
- if (NULL == http->storeEntry()) {
+ if (!e) {
/** \li If no StoreEntry object is current assume this object isn't in the cache set MISS*/
debugs(85, 3, "StoreEntry is NULL - MISS");
http->logType.update(LOG_TCP_MISS);
if (!checkHitRequest) {
debugs(31, 3, "htcpCheckHit: NO; failed to parse URL");
- checkedHit(NullStoreEntry::getInstance());
+ checkedHit(nullptr);
return;
}
if (!checkHitRequest->header.parse(req_hdrs, reqHdrsSz)) {
debugs(31, 3, "htcpCheckHit: NO; failed to parse request headers");
checkHitRequest = nullptr;
- checkedHit(NullStoreEntry::getInstance());
+ checkedHit(nullptr);
return;
}
{
StoreEntry *hit = nullptr;
- if (!e || e->isNull()) {
+ if (!e) {
debugs(31, 3, "htcpCheckHit: NO; public object not found");
} else if (!e->validToSend()) {
debugs(31, 3, "htcpCheckHit: NO; entry not valid to send" );
checkedHit(hit);
// TODO: StoreClients must either store/lock or abandon found entries.
- //if (!e->isNull())
+ //if (e)
// e->abandon();
}
bool
ICPState::confirmAndPrepHit(const StoreEntry &e)
{
- if (e.isNull())
- return false;
-
if (!e.validToSend())
return false;
debugs(12, 5, "icpHandleIcpV2: OPCODE " << icp_opcode_str[header.opcode]);
icp_opcode codeToSend;
- if (confirmAndPrepHit(*e)) {
+ if (e && confirmAndPrepHit(*e)) {
codeToSend = ICP_HIT;
} else {
#if USE_ICMP
icpCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, from, al);
// TODO: StoreClients must either store/lock or abandon found entries.
- //if (!e->isNull())
+ //if (e)
// e->abandon();
delete this;
debugs(12, 5, "icpHandleIcpV3: OPCODE " << icp_opcode_str[header.opcode]);
icp_opcode codeToSend;
- if (confirmAndPrepHit(*e)) {
+ if (e && confirmAndPrepHit(*e)) {
codeToSend = ICP_HIT;
} else if (icpGetCommonOpcode() == ICP_ERR)
codeToSend = ICP_MISS;
icpCreateAndSend(codeToSend, 0, url, header.reqnum, 0, fd, from, al);
// TODO: StoreClients must either store/lock or abandon found entries.
- //if (!e->isNull())
+ //if (e)
// e->abandon();
delete this;
MimeIcon::created(StoreEntry *newEntry)
{
/* if the icon is already in the store, do nothing */
- if (!newEntry->isNull())
+ if (newEntry)
return;
// XXX: if a 204 is cached due to earlier load 'failure' we should try to reload.
StoreEntry *e = static_cast<StoreEntry *>(static_cast<hash_link *>(data));
assert(e != NULL);
- if (e == NullStoreEntry::getInstance())
- return;
-
// Store::Root() is FATALly missing during shutdown
if (e->hasDisk() && !shutting_down)
e->disk().disconnect(*e);
StoreEntry::getPublicByRequestMethod (StoreClient *aClient, HttpRequest * request, const HttpRequestMethod& method)
{
assert (aClient);
- StoreEntry *result = storeGetPublicByRequestMethod( request, method);
-
- if (!result)
- aClient->created (NullStoreEntry::getInstance());
- else
- aClient->created (result);
+ aClient->created(storeGetPublicByRequestMethod(request, method));
}
void
StoreEntry::getPublicByRequest (StoreClient *aClient, HttpRequest * request)
{
assert (aClient);
- StoreEntry *result = storeGetPublicByRequest (request);
-
- if (!result)
- result = NullStoreEntry::getInstance();
-
- aClient->created (result);
+ aClient->created(storeGetPublicByRequest(request));
}
void
StoreEntry::getPublic (StoreClient *aClient, const char *uri, const HttpRequestMethod& method)
{
assert (aClient);
- StoreEntry *result = storeGetPublic (uri, method);
-
- if (!result)
- result = NullStoreEntry::getInstance();
-
- aClient->created (result);
+ aClient->created(storeGetPublic(uri, method));
}
StoreEntry *
return os << '/' << &e << '*' << e.locks();
}
-/* NullStoreEntry */
-
-NullStoreEntry NullStoreEntry::_instance;
-
-NullStoreEntry *
-NullStoreEntry::getInstance()
-{
- return &_instance;
-}
-
-char const *
-NullStoreEntry::getMD5Text() const
-{
- return "N/A";
-}
-
-void
-NullStoreEntry::operator delete(void*)
-{
- fatal ("Attempt to delete NullStoreEntry\n");
-}
-
-char const *
-NullStoreEntry::getSerialisedMetaData()
-{
- return NULL;
-}
-
void
Store::EntryGuard::onException() noexcept
{
void StoreEntry::vappendf(const char *, va_list) STUB
void StoreEntry::setCollapsingRequirement(const bool required) STUB
-NullStoreEntry *NullStoreEntry::getInstance() STUB_RETVAL(NULL)
-const char *NullStoreEntry::getMD5Text() const STUB_RETVAL(NULL)
-void NullStoreEntry::operator delete(void *address) STUB
-// private virtual. Why is this linked from outside?
-const char *NullStoreEntry::getSerialisedMetaData() STUB_RETVAL(NULL)
-
Store::Controller &Store::Root() STUB_RETREF(Store::Controller)
void Store::Init(Store::Controller *root) STUB
void Store::FreeMemory() STUB
TestStore *aStore(new TestStore);
Store::Init(aStore);
CPPUNIT_ASSERT_EQUAL(false, aStore->statsCalled);
- Store::Stats(NullStoreEntry::getInstance());
+ StoreEntry entry;
+ Store::Stats(&entry);
CPPUNIT_ASSERT_EQUAL(true, aStore->statsCalled);
Store::FreeMemory();
}
void
UrnState::created(StoreEntry *e)
{
- if (e->isNull() || (e->hittingRequiresCollapsing() && !startCollapsingOn(*e, false))) {
+ if (!e || (e->hittingRequiresCollapsing() && !startCollapsingOn(*e, false))) {
urlres_e = storeCreateEntry(urlres, urlres, RequestFlags(), Http::METHOD_GET);
sc = storeClientListAdd(urlres_e, this);
FwdState::Start(Comm::ConnectionPointer(), urlres_e, urlres_r.getRaw(), ale);
// TODO: StoreClients must either store/lock or abandon found entries.
- //if (!e->isNull())
+ //if (e)
// e->abandon();
} else {
urlres_e = e;