/*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* ->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()) {
timestamp(-1),
lastref(-1),
expires(-1),
- lastmod(-1),
+ lastModified_(-1),
swap_file_sz(0),
refcount(0),
flags(0),
StoreEntry::calcPublicKey(const KeyScope keyScope)
{
assert(mem_obj);
- return mem_obj->request ? storeKeyPublicByRequest(mem_obj->request, keyScope) :
+ return mem_obj->request ? storeKeyPublicByRequest(mem_obj->request.getRaw(), keyScope) :
storeKeyPublic(mem_obj->storeId(), mem_obj->method, keyScope);
}
if (!mem_obj->request)
return;
- HttpRequest *request = mem_obj->request;
+ HttpRequestPointer request(mem_obj->request);
if (mem_obj->vary_headers.isEmpty()) {
/* First handle the case where the object no longer varies */
/* Make sure the request knows the variance status */
if (request->vary_headers.isEmpty())
- request->vary_headers = httpMakeVaryMark(request, mem_obj->getReply());
+ request->vary_headers = httpMakeVaryMark(request.getRaw(), mem_obj->getReply().getRaw());
}
// TODO: storeGetPublic() calls below may create unlocked entries.
assert(store_status == STORE_PENDING);
// XXX: caller uses content offset, but we also store headers
- if (const HttpReply *reply = mem_obj->getReply())
+ if (const HttpReplyPointer reply = mem_obj->getReply())
writeBuffer.offset += reply->hdr_sz;
debugs(20, 5, "storeWrite: writing " << writeBuffer.length << " bytes for '" << getMD5Text() << "'");
else
exp = reply->expires;
- if (lastmod == reply->last_modified && timestamp == served_date && expires == exp)
- return false;
+ if (timestamp == served_date && expires == exp) {
+ // if the reply lacks LMT, then we now know that our effective
+ // LMT (i.e., timestamp) will stay the same, otherwise, old and
+ // new modification times must match
+ if (reply->last_modified < 0 || reply->last_modified == lastModified())
+ return false; // nothing has changed
+ }
expires = exp;
- lastmod = reply->last_modified;
+ lastModified_ = reply->last_modified;
timestamp = served_date;
debugs(20, l, "StoreEntry->timestamp: " << timestamp);
debugs(20, l, "StoreEntry->lastref: " << lastref);
debugs(20, l, "StoreEntry->expires: " << expires);
- debugs(20, l, "StoreEntry->lastmod: " << lastmod);
+ debugs(20, l, "StoreEntry->lastModified_: " << lastModified_);
debugs(20, l, "StoreEntry->swap_file_sz: " << swap_file_sz);
debugs(20, l, "StoreEntry->refcount: " << refcount);
debugs(20, l, "StoreEntry->flags: " << storeEntryFlags(this));
}
HttpReply const *
-StoreEntry::getReply () const
+StoreEntry::getReply() const
{
- if (NULL == mem_obj)
- return NULL;
-
- return mem_obj->getReply();
+ return (mem_obj ? mem_obj->getReply().getRaw() : nullptr);
}
void
StoreEntry::reset()
{
assert (mem_obj);
- debugs(20, 3, "StoreEntry::reset: " << url());
+ debugs(20, 3, url());
mem_obj->reset();
- HttpReply *rep = (HttpReply *) getReply(); // bypass const
- rep->reset();
- expires = lastmod = timestamp = -1;
+ expires = lastModified_ = timestamp = -1;
}
/*
return;
}
- mem_obj->replaceHttpReply(rep);
+ mem_obj->replaceReply(HttpReplyPointer(rep));
if (andStartWriting)
startWriting();
}
bool
-StoreEntry::modifiedSince(HttpRequest * request) const
+StoreEntry::modifiedSince(const time_t ims, const int imslen) const
{
int object_length;
- time_t mod_time = lastmod;
-
- if (mod_time < 0)
- mod_time = timestamp;
+ const time_t mod_time = lastModified();
debugs(88, 3, "modifiedSince: '" << url() << "'");
if (object_length < 0)
object_length = contentLen();
- if (mod_time > request->ims) {
+ if (mod_time > ims) {
debugs(88, 3, "--> YES: entry newer than client");
return true;
- } else if (mod_time < request->ims) {
+ } else if (mod_time < ims) {
debugs(88, 3, "--> NO: entry older than client");
return false;
- } else if (request->imslen < 0) {
+ } else if (imslen < 0) {
debugs(88, 3, "--> NO: same LMT, no client length");
return false;
- } else if (request->imslen == object_length) {
+ } else if (imslen == object_length) {
debugs(88, 3, "--> NO: same LMT, same length");
return false;
} else {
return true;
}
+const char *
+StoreEntry::describeTimestamps() const
+{
+ LOCAL_ARRAY(char, buf, 256);
+ snprintf(buf, 256, "LV:%-9d LU:%-9d LM:%-9d EX:%-9d",
+ static_cast<int>(timestamp),
+ static_cast<int>(lastref),
+ static_cast<int>(lastModified_),
+ static_cast<int>(expires));
+ return buf;
+}
+
std::ostream &operator <<(std::ostream &os, const StoreEntry &e)
{
os << "e:";
// print only set flags, using unique letters
if (e.flags) {
if (EBIT_TEST(e.flags, ENTRY_SPECIAL)) os << 'S';
- if (EBIT_TEST(e.flags, ENTRY_REVALIDATE)) os << 'R';
+ if (EBIT_TEST(e.flags, ENTRY_REVALIDATE_ALWAYS)) os << 'R';
if (EBIT_TEST(e.flags, DELAY_SENDING)) os << 'P';
if (EBIT_TEST(e.flags, RELEASE_REQUEST)) os << 'X';
if (EBIT_TEST(e.flags, REFRESH_REQUEST)) os << 'F';
+ if (EBIT_TEST(e.flags, ENTRY_REVALIDATE_STALE)) os << 'E';
if (EBIT_TEST(e.flags, ENTRY_DISPATCHED)) os << 'D';
if (EBIT_TEST(e.flags, KEY_PRIVATE)) os << 'I';
if (EBIT_TEST(e.flags, ENTRY_FWD_HDR_WAIT)) os << 'W';