#include <StoreClient.h>
![Collaboration graph](classstore__client__coll__graph.png)
Classes | |
struct | Callback |
Public Member Functions | |
void * | operator new (size_t size) |
void | operator delete (void *address) |
void * | toCbdata () noexcept |
store_client (StoreEntry *) | |
~store_client () | |
auto | discardableHttpEnd () const |
the client will not use HTTP response bytes with lower offsets (if any) More... | |
int | getType () const |
void | noteSwapInDone (bool error) |
void | doCopy (StoreEntry *e) |
void | readHeader (const char *buf, ssize_t len) |
void | readBody (const char *buf, ssize_t len) |
void | copy (StoreEntry *, StoreIOBuffer, STCB *, void *) |
void | dumpStats (MemBuf *output, int clientNumber) const |
bool | atEof () const |
int | bytesWanted () const |
void | setDelayId (DelayId delay_id) |
Public Attributes | |
StoreEntry * | entry |
StoreIOState::Pointer | swapin_sio |
struct { | |
bool disk_io_pending | |
bool store_copying | |
} | flags |
DelayId | delayId |
dlink_node | node |
struct store_client::Callback | _callback |
Private Member Functions | |
bool | moreToRead () const |
Whether Store has (or possibly will have) more entry data for us. More... | |
bool | canReadFromMemory () const |
whether at least one byte wanted by the client is in memory More... | |
bool | answeredOnce () const |
bool | sendingHttpHeaders () const |
int64_t | nextHttpReadOffset () const |
The offset of the next stored HTTP response byte wanted by the client. More... | |
void | fileRead () |
void | scheduleDiskRead () |
void | readFromMemory () |
void | scheduleRead () |
bool | startSwapin () |
opens the swapin "file" if possible; otherwise, fail()s and returns false More... | |
void | handleBodyFromDisk () |
de-serializes HTTP response (partially) read from disk storage More... | |
void | maybeWriteFromDiskToMemory (const StoreIOBuffer &) |
bool | parseHttpHeadersFromDisk () |
bool | tryParsingHttpHeaders () |
void | skipHttpHeadersFromDisk () |
skips HTTP header bytes previously loaded from disk More... | |
void | fail () |
void | callback (ssize_t) |
void | noteCopiedBytes (size_t) |
void | noteNews () |
if necessary and possible, informs the Store reader about copy() result More... | |
void | finishCallback () |
finishes a copy()-STCB sequence by synchronously calling STCB More... | |
Static Private Member Functions | |
static void | FinishCallback (store_client *) |
finishCallback() wrapper; TODO: Add NullaryMemFunT for non-jobs. More... | |
Private Attributes | |
int | type |
bool | object_ok |
bool | atEof_ |
StoreIOBuffer | copyInto |
int64_t | discardableHttpEnd_ = 0 |
the client will not use HTTP response bytes with lower offsets (if any) More... | |
uint64_t | answers |
the total number of finishCallback() calls More... | |
std::optional< Store::ParsingBuffer > | parsingBuffer |
StoreIOBuffer | lastDiskRead |
buffer used for the last storeRead() call More... | |
Static Private Attributes | |
static cbdata_type | CBDATA_store_client = CBDATA_UNKNOWN |
Detailed Description
Definition at line 73 of file StoreClient.h.
Constructor & Destructor Documentation
◆ store_client()
|
explicit |
Definition at line 192 of file store_client.cc.
References assert, Assure, entry, flags, getType(), StoreEntry::hasDisk(), StoreEntry::lock(), StoreEntry::refcount, STORE_DISK_CLIENT, and StoreEntry::swapoutFailed().
◆ ~store_client()
store_client::~store_client | ( | ) |
Definition at line 216 of file store_client.cc.
References assert, entry, and StoreEntry::unlock().
Member Function Documentation
◆ answeredOnce()
|
inlineprivate |
Definition at line 144 of file StoreClient.h.
References answers.
Referenced by copy(), handleBodyFromDisk(), readBody(), and sendingHttpHeaders().
◆ atEof()
|
inline |
Whether the last successful storeClientCopy() answer was known to contain the last body bytes of the HTTP response
- Return values
-
true requesting bytes at higher offsets is futile
- See also
- STCB
Definition at line 106 of file StoreClient.h.
References atEof_.
Referenced by asHandleReply(), netdbExchangeHandleReply(), peerDigestHandleReply(), and urnHandleReply().
◆ bytesWanted()
int store_client::bytesWanted | ( | ) | const |
The maximum number of bytes the Store client can read/copy next without overflowing its buffer and without violating delay pool limits. Store I/O is not rate-limited, but we assume that the same number of bytes may be read from the Squid-to-server connection that may be rate-limited.
Definition at line 1092 of file store_client.cc.
References DelayId::bytesWanted(), copyInto, delayId, and StoreIOBuffer::length.
◆ callback()
|
private |
◆ canReadFromMemory()
|
private |
Definition at line 497 of file store_client.cc.
References MemObject::endOffset(), entry, MemObject::inmem_lo, StoreEntry::mem(), nextHttpReadOffset(), and parsingBuffer.
Referenced by doCopy(), and moreToRead().
◆ copy()
void store_client::copy | ( | StoreEntry * | anEntry, |
StoreIOBuffer | copyRequest, | ||
STCB * | callback_fn, | ||
void * | data | ||
) |
Request StoreIOBuffer-described response data via an asynchronous STCB callback. At most one outstanding request is allowed per store_client.
Definition at line 235 of file store_client.cc.
References _callback, answeredOnce(), assert, Assure, copyInto, StoreIOBuffer::data, debugs, discardableHttpEnd_, EBIT_TEST, entry, ENTRY_ABORTED, StoreEntry::flags, StoreEntry::getMD5Text(), StoreEntry::kickProducer(), MemObject::kickReads(), StoreIOBuffer::length, StoreEntry::lock(), StoreEntry::mem_obj, nextHttpReadOffset(), StoreIOBuffer::offset, parsingBuffer, store_client::Callback::pending(), storeClientCopy2(), and StoreEntry::unlock().
◆ discardableHttpEnd()
|
inline |
Definition at line 82 of file StoreClient.h.
References discardableHttpEnd_.
Referenced by LowestMemReader::operator()().
◆ doCopy()
void store_client::doCopy | ( | StoreEntry * | e | ) |
Definition at line 365 of file store_client.cc.
References _callback, answers, assert, Assure, MemObject::baseReply(), canReadFromMemory(), copyInto, debugs, MemObject::endOffset(), entry, flags, getType(), Http::Message::hdr_sz, StoreEntry::mem_obj, moreToRead(), nextHttpReadOffset(), noteNews(), StoreEntry::objectLen(), store_client::Callback::pending(), readFromMemory(), scheduleDiskRead(), sendingHttpHeaders(), startSwapin(), STORE_DISK_CLIENT, STORE_PENDING, StoreEntry::store_status, and swapin_sio.
◆ dumpStats()
Definition at line 1055 of file store_client.cc.
References _callback, MemBuf::append(), Packable::appendf(), copyInto, flags, StoreIOBuffer::length, store_client::Callback::notifier, StoreIOBuffer::offset, store_client::Callback::pending(), and PRId64.
Referenced by StoreClientStats::operator()().
◆ fail()
|
private |
Definition at line 674 of file store_client.cc.
References debugs, noteNews(), and object_ok.
Referenced by noteSwapInDone(), parseHttpHeadersFromDisk(), readBody(), readHeader(), and startSwapin().
◆ fileRead()
|
private |
Definition at line 537 of file store_client.cc.
References _callback, assert, Assure, copyInto, StoreIOBuffer::data, debugs, entry, flags, lastDiskRead, StoreIOBuffer::length, StoreEntry::mem_obj, min(), nextHttpReadOffset(), StoreIOState::offset(), StoreIOBuffer::offset, parsingBuffer, store_client::Callback::pending(), MemObject::SwapOut::sio, SM_PAGE_SIZE, storeClientReadBody, storeClientReadHeader, storeRead(), MemObject::swap_hdr_sz, swapin_sio, MemObject::swapout, and StoreEntry::swappingOut().
Referenced by scheduleDiskRead().
◆ finishCallback()
|
private |
Definition at line 154 of file store_client.cc.
References _callback, answers, Assure, atEof_, MemObject::baseReply(), store_client::Callback::callback_handler, store_client::Callback::cbData, copyInto, StoreIOBuffer::data, debugs, discardableHttpEnd_, MemObject::endOffset(), entry, Http::Message::hdr_sz, StoreIOBuffer::length, StoreEntry::mem(), store_client::Callback::notifier, object_ok, StoreIOBuffer::offset, parsingBuffer, sendingHttpHeaders(), and CallbackData::validDone().
◆ FinishCallback()
|
staticprivate |
◆ getType()
int store_client::getType | ( | ) | const |
Definition at line 91 of file store_client.cc.
References type.
Referenced by doCopy(), LowestMemReader::operator()(), scheduleDiskRead(), and store_client().
◆ handleBodyFromDisk()
|
private |
Definition at line 627 of file store_client.cc.
References answeredOnce(), Assure, entry, StoreEntry::hasParsedReplyHeader(), StoreEntry::mem_obj, noteNews(), parseHttpHeadersFromDisk(), skipHttpHeadersFromDisk(), and MemObject::swap_hdr_sz.
Referenced by readBody(), and readHeader().
◆ maybeWriteFromDiskToMemory()
|
private |
Adds HTTP response data loaded from disk to the memory cache (if needed/possible). The given part may contain portions of HTTP response headers and/or HTTP response body.
Definition at line 650 of file store_client.cc.
References Config, MemObject::endOffset(), entry, MemObject::inmem_lo, StoreIOBuffer::length, SquidConfig::maxInMemObjSize, StoreEntry::mem_obj, SquidConfig::memory_cache_disk, StoreEntry::objectLen(), StoreIOBuffer::offset, SquidConfig::onoff, SquidConfig::Store, storeGetMemSpace(), and MemObject::write().
Referenced by readBody(), and readHeader().
◆ moreToRead()
|
private |
Definition at line 308 of file store_client.cc.
References canReadFromMemory(), StoreEntry::contentLen(), copyInto, entry, StoreEntry::hasDisk(), StoreIOBuffer::length, StoreEntry::objectLen(), StoreIOBuffer::offset, STORE_PENDING, and StoreEntry::store_status.
Referenced by doCopy().
◆ nextHttpReadOffset()
|
private |
Definition at line 508 of file store_client.cc.
References Assure, MemObject::baseReply(), copyInto, entry, Http::Message::hdr_sz, StoreEntry::mem(), StoreIOBuffer::offset, and parsingBuffer.
Referenced by canReadFromMemory(), copy(), doCopy(), fileRead(), and readFromMemory().
◆ noteCopiedBytes()
|
private |
◆ noteNews()
|
private |
Definition at line 687 of file store_client.cc.
References _callback, Assure, asyncCall(), store_client::Callback::callback_handler, cbdataDialer(), debugs, FinishCallback(), store_client::Callback::notifier, store_client::Callback::pending(), and ScheduleCallHere.
Referenced by doCopy(), fail(), handleBodyFromDisk(), noteSwapInDone(), and readBody().
◆ noteSwapInDone()
void store_client::noteSwapInDone | ( | bool | error | ) |
React to the end of reading the response from disk. There will be no more readHeader() and readBody() callbacks for the current storeRead() swapin after this notification.
Definition at line 464 of file store_client.cc.
References _callback, Assure, error(), fail(), noteNews(), and store_client::Callback::pending().
◆ operator delete()
|
inline |
Definition at line 75 of file StoreClient.h.
◆ operator new()
|
inline |
Definition at line 75 of file StoreClient.h.
◆ parseHttpHeadersFromDisk()
|
private |
parses HTTP header bytes loaded from disk
- Returns
- false if fail() or scheduleDiskRead() has been called and, hence, the caller should just quit without any further action
Definition at line 1001 of file store_client.cc.
References CurrentException(), DBG_CRITICAL, debugs, Debug::Extra(), fail(), parsingBuffer, and tryParsingHttpHeaders().
Referenced by handleBodyFromDisk().
◆ readBody()
void store_client::readBody | ( | const char * | buf, |
ssize_t | len | ||
) |
Definition at line 586 of file store_client.cc.
References _callback, answeredOnce(), assert, Assure, StoreIOBuffer::data, DBG_CRITICAL, debugs, entry, fail(), flags, handleBodyFromDisk(), lastDiskRead, StoreIOBuffer::length, Less(), maybeWriteFromDiskToMemory(), StoreEntry::mem(), noteNews(), StoreIOBuffer::offset, parsingBuffer, store_client::Callback::pending(), StoreIOBuffer::positionAt(), and MemObject::swap_hdr_sz.
◆ readFromMemory()
|
private |
Copies at least some of the requested body bytes from MemObject memory, satisfying the copy() request.
- Precondition
- canReadFromMemory() is true
Definition at line 525 of file store_client.cc.
References Assure, mem_hdr::copy(), MemObject::data_hdr, debugs, entry, StoreEntry::mem_obj, nextHttpReadOffset(), and parsingBuffer.
Referenced by doCopy().
◆ readHeader()
void store_client::readHeader | ( | const char * | buf, |
ssize_t | len | ||
) |
Definition at line 727 of file store_client.cc.
References _callback, assert, Assure, CurrentException(), DBG_IMPORTANT, debugs, entry, fail(), flags, handleBodyFromDisk(), maybeWriteFromDiskToMemory(), StoreEntry::mem_obj, object_ok, parsingBuffer, store_client::Callback::pending(), MemObject::swap_hdr_sz, and Store::UnpackHitSwapMeta().
◆ scheduleDiskRead()
|
private |
Definition at line 474 of file store_client.cc.
References assert, debugs, entry, fileRead(), flags, getType(), startSwapin(), STORE_DISK_CLIENT, and swapin_sio.
Referenced by doCopy(), and tryParsingHttpHeaders().
◆ scheduleRead()
|
private |
◆ sendingHttpHeaders()
|
private |
Whether our answer, if sent right now, will announce the availability of HTTP response headers (to the STCB callback) for the first time.
Definition at line 359 of file store_client.cc.
References answeredOnce(), MemObject::baseReply(), entry, Http::Message::hdr_sz, and StoreEntry::mem().
Referenced by doCopy(), and finishCallback().
◆ setDelayId()
void store_client::setDelayId | ( | DelayId | delay_id | ) |
Definition at line 1099 of file store_client.cc.
References delayId.
Referenced by clientReplyContext::createStoreEntry(), clientReplyContext::doGetMoreData(), clientReplyContext::processExpired(), clientReplyContext::sendMoreData(), Ssl::ServerBump::ServerBump(), and clientReplyContext::setReplyToStoreEntry().
◆ skipHttpHeadersFromDisk()
|
private |
Definition at line 1039 of file store_client.cc.
References Assure, MemObject::baseReply(), copyInto, debugs, entry, Http::Message::hdr_sz, StoreIOBuffer::length, Less(), StoreEntry::mem_obj, and parsingBuffer.
Referenced by handleBodyFromDisk().
◆ startSwapin()
|
private |
Definition at line 435 of file store_client.cc.
References DBG_IMPORTANT, debugs, fail(), flags, storeSwapInStart(), storeTooManyDiskFilesOpen(), and swapin_sio.
Referenced by doCopy(), and scheduleDiskRead().
◆ toCbdata()
|
inlinenoexcept |
Definition at line 75 of file StoreClient.h.
◆ tryParsingHttpHeaders()
|
private |
parseHttpHeadersFromDisk() helper
Definition at line 1021 of file store_client.cc.
References MemObject::adjustableBaseReply(), Assure, copyInto, entry, StoreEntry::mem(), StoreIOBuffer::offset, parsingBuffer, and scheduleDiskRead().
Referenced by parseHttpHeadersFromDisk().
Member Data Documentation
◆ _callback
struct store_client::Callback store_client::_callback |
Referenced by copy(), doCopy(), dumpStats(), fileRead(), finishCallback(), noteNews(), noteSwapInDone(), readBody(), and readHeader().
◆ answers
|
private |
Definition at line 186 of file StoreClient.h.
Referenced by answeredOnce(), doCopy(), and finishCallback().
◆ atEof_
|
private |
Whether the last successful storeClientCopy() answer was known to contain the last body bytes of the HTTP response
- Return values
-
true requesting bytes at higher offsets is futile
- See also
- STCB
Definition at line 171 of file StoreClient.h.
Referenced by atEof(), and finishCallback().
◆ CBDATA_store_client
|
staticprivate |
Definition at line 75 of file StoreClient.h.
◆ copyInto
|
private |
Storage and metadata associated with the current copy() request. Ought to be ignored when not answering a copy() request.
- copyInto.offset is the requested HTTP response body offset;
- copyInto.data is the client-owned, client-provided result buffer;
- copyInto.length is the size of the .data result buffer;
- copyInto.flags are unused by this class.
Definition at line 179 of file StoreClient.h.
Referenced by bytesWanted(), copy(), doCopy(), dumpStats(), fileRead(), finishCallback(), moreToRead(), nextHttpReadOffset(), skipHttpHeadersFromDisk(), and tryParsingHttpHeaders().
◆ delayId
DelayId store_client::delayId |
Definition at line 128 of file StoreClient.h.
Referenced by bytesWanted(), and setDelayId().
◆ discardableHttpEnd_
|
private |
Definition at line 183 of file StoreClient.h.
Referenced by copy(), discardableHttpEnd(), and finishCallback().
◆ disk_io_pending
bool store_client::disk_io_pending |
whether we are expecting a response to be swapped in from disk (i.e. whether async storeRead() is currently in progress)
Definition at line 120 of file StoreClient.h.
◆ entry
StoreEntry* store_client::entry |
Definition at line 113 of file StoreClient.h.
Referenced by canReadFromMemory(), copy(), doCopy(), fileRead(), finishCallback(), handleBodyFromDisk(), maybeWriteFromDiskToMemory(), moreToRead(), nextHttpReadOffset(), readBody(), readFromMemory(), readHeader(), scheduleDiskRead(), sendingHttpHeaders(), skipHttpHeadersFromDisk(), store_client(), tryParsingHttpHeaders(), and ~store_client().
◆ flags
struct { ... } store_client::flags |
Referenced by doCopy(), dumpStats(), fileRead(), readBody(), readHeader(), scheduleDiskRead(), startSwapin(), and store_client().
◆ lastDiskRead
|
private |
Definition at line 194 of file StoreClient.h.
Referenced by fileRead(), and readBody().
◆ node
dlink_node store_client::node |
Definition at line 139 of file StoreClient.h.
Referenced by MemObject::addClient().
◆ object_ok
|
private |
Definition at line 168 of file StoreClient.h.
Referenced by fail(), finishCallback(), and readHeader().
◆ parsingBuffer
|
private |
Accumulates raw bytes read from Store while answering the current copy() request. Buffer contents depends on the source and parsing stage; it may hold (parts of) swap metadata, HTTP response headers, and/or HTTP response body bytes.
Definition at line 192 of file StoreClient.h.
Referenced by canReadFromMemory(), copy(), fileRead(), finishCallback(), nextHttpReadOffset(), parseHttpHeadersFromDisk(), readBody(), readFromMemory(), readHeader(), skipHttpHeadersFromDisk(), and tryParsingHttpHeaders().
◆ store_copying
bool store_client::store_copying |
whether the store_client::doCopy()-initiated STCB sequence is currently in progress
Definition at line 124 of file StoreClient.h.
◆ swapin_sio
StoreIOState::Pointer store_client::swapin_sio |
Definition at line 114 of file StoreClient.h.
Referenced by doCopy(), fileRead(), scheduleDiskRead(), and startSwapin().
◆ type
|
private |
Definition at line 167 of file StoreClient.h.
Referenced by getType().
The documentation for this class was generated from the following files:
- src/StoreClient.h
- src/store_client.cc
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products