#include <StoreClient.h>
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 () | |
int64_t | readOffset () const |
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 |
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 69 of file StoreClient.h.
Constructor & Destructor Documentation
◆ store_client()
|
explicit |
Definition at line 181 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 205 of file store_client.cc.
References assert, entry, and StoreEntry::unlock().
Member Function Documentation
◆ answeredOnce()
|
inlineprivate |
Definition at line 147 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 109 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 1082 of file store_client.cc.
References DelayId::bytesWanted(), copyInto, delayId, and StoreIOBuffer::length.
◆ callback()
|
private |
◆ canReadFromMemory()
|
private |
Definition at line 482 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 224 of file store_client.cc.
References _callback, answeredOnce(), assert, Assure, copyInto, StoreIOBuffer::data, debugs, EBIT_TEST, entry, ENTRY_ABORTED, StoreEntry::flags, StoreEntry::getMD5Text(), StoreEntry::kickProducer(), MemObject::kickReads(), StoreIOBuffer::length, StoreEntry::lock(), StoreEntry::mem_obj, StoreIOBuffer::offset, parsingBuffer, store_client::Callback::pending(), storeClientCopy2(), and StoreEntry::unlock().
◆ doCopy()
void store_client::doCopy | ( | StoreEntry * | e | ) |
Definition at line 351 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 1045 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 658 of file store_client.cc.
References debugs, noteNews(), and object_ok.
Referenced by noteSwapInDone(), parseHttpHeadersFromDisk(), readBody(), readHeader(), and startSwapin().
◆ fileRead()
|
private |
Definition at line 521 of file store_client.cc.
References _callback, assert, Assure, copyInto, StoreIOBuffer::data, debugs, entry, flags, lastDiskRead, StoreIOBuffer::length, StoreEntry::mem_obj, min(), nextHttpReadOffset(), StoreIOBuffer::offset, StoreIOState::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 153 of file store_client.cc.
References _callback, answers, Assure, atEof_, store_client::Callback::callback_handler, store_client::Callback::cbData, copyInto, StoreIOBuffer::data, StoreIOBuffer::length, store_client::Callback::notifier, object_ok, StoreIOBuffer::offset, parsingBuffer, sendingHttpHeaders(), and CallbackData::validDone().
◆ FinishCallback()
|
staticprivate |
◆ getType()
int store_client::getType | ( | ) | const |
Definition at line 90 of file store_client.cc.
References type.
Referenced by store_client(), doCopy(), LowestMemReader::operator()(), and scheduleDiskRead().
◆ handleBodyFromDisk()
|
private |
Definition at line 611 of file store_client.cc.
References answeredOnce(), Assure, MemObject::baseReply(), entry, StoreEntry::mem_obj, noteNews(), parseHttpHeadersFromDisk(), Http::Message::psParsed, Http::Message::pstate, 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 634 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 294 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 492 of file store_client.cc.
References Assure, MemObject::baseReply(), copyInto, entry, Http::Message::hdr_sz, StoreEntry::mem(), StoreIOBuffer::offset, and parsingBuffer.
Referenced by canReadFromMemory(), doCopy(), fileRead(), and readFromMemory().
◆ noteCopiedBytes()
|
private |
◆ noteNews()
|
private |
Definition at line 671 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 449 of file store_client.cc.
References _callback, Assure, error(), fail(), noteNews(), and store_client::Callback::pending().
◆ operator delete()
|
inline |
Definition at line 71 of file StoreClient.h.
◆ operator new()
|
inline |
Definition at line 71 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 991 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 570 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 509 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 711 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().
◆ readOffset()
|
inline |
An offset into the stored response bytes, including the HTTP response headers (if any). Note that this offset does not include Store entry metadata, because it is not a part of the stored response.
- Return values
-
0 means the client wants to read HTTP response headers. +N the response byte that the client wants to read next. -N should not occur.
Definition at line 85 of file StoreClient.h.
References copyInto, and StoreIOBuffer::offset.
Referenced by LowestMemReader::operator()().
◆ scheduleDiskRead()
|
private |
Definition at line 459 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 345 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 1089 of file store_client.cc.
References delayId.
Referenced by Ssl::ServerBump::ServerBump(), clientReplyContext::createStoreEntry(), clientReplyContext::doGetMoreData(), clientReplyContext::processExpired(), clientReplyContext::sendMoreData(), and clientReplyContext::setReplyToStoreEntry().
◆ skipHttpHeadersFromDisk()
|
private |
Definition at line 1029 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 420 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 71 of file StoreClient.h.
◆ tryParsingHttpHeaders()
|
private |
parseHttpHeadersFromDisk() helper
Definition at line 1011 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 181 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 174 of file StoreClient.h.
Referenced by atEof(), and finishCallback().
◆ CBDATA_store_client
|
staticprivate |
Definition at line 71 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.
Definition at line 178 of file StoreClient.h.
Referenced by bytesWanted(), copy(), doCopy(), dumpStats(), fileRead(), finishCallback(), moreToRead(), nextHttpReadOffset(), readOffset(), skipHttpHeadersFromDisk(), and tryParsingHttpHeaders().
◆ delayId
DelayId store_client::delayId |
Definition at line 131 of file StoreClient.h.
Referenced by bytesWanted(), and setDelayId().
◆ 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 123 of file StoreClient.h.
◆ entry
StoreEntry* store_client::entry |
Definition at line 116 of file StoreClient.h.
Referenced by store_client(), ~store_client(), canReadFromMemory(), copy(), doCopy(), fileRead(), handleBodyFromDisk(), maybeWriteFromDiskToMemory(), moreToRead(), nextHttpReadOffset(), readBody(), readFromMemory(), readHeader(), scheduleDiskRead(), sendingHttpHeaders(), skipHttpHeadersFromDisk(), and tryParsingHttpHeaders().
◆
struct { ... } store_client::flags |
Referenced by store_client(), doCopy(), dumpStats(), fileRead(), readBody(), readHeader(), scheduleDiskRead(), and startSwapin().
◆ lastDiskRead
|
private |
Definition at line 189 of file StoreClient.h.
Referenced by fileRead(), and readBody().
◆ node
dlink_node store_client::node |
Definition at line 142 of file StoreClient.h.
Referenced by MemObject::addClient().
◆ object_ok
|
private |
Definition at line 171 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 187 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 127 of file StoreClient.h.
◆ swapin_sio
StoreIOState::Pointer store_client::swapin_sio |
Definition at line 117 of file StoreClient.h.
Referenced by doCopy(), fileRead(), scheduleDiskRead(), and startSwapin().
◆ type
|
private |
Definition at line 170 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