#include <StoreClient.h>

Collaboration diagram for store_client:

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

StoreEntryentry
 
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::ParsingBufferparsingBuffer
 
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()

store_client::store_client ( StoreEntry e)
explicit

◆ ~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()

bool store_client::answeredOnce ( ) const
inlineprivate

Definition at line 147 of file StoreClient.h.

References answers.

Referenced by copy(), handleBodyFromDisk(), readBody(), and sendingHttpHeaders().

◆ atEof()

bool store_client::atEof ( ) const
inline

Whether the last successful storeClientCopy() answer was known to contain the last body bytes of the HTTP response

Return values
truerequesting 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()

void store_client::callback ( ssize_t  )
private

◆ canReadFromMemory()

bool store_client::canReadFromMemory ( ) const
private

◆ copy()

void store_client::copy ( StoreEntry anEntry,
StoreIOBuffer  copyRequest,
STCB callback_fn,
void *  data 
)

◆ doCopy()

◆ dumpStats()

void store_client::dumpStats ( MemBuf output,
int  clientNumber 
) const

◆ fail()

void store_client::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()

◆ finishCallback()

◆ FinishCallback()

void store_client::FinishCallback ( store_client sc)
staticprivate

Definition at line 146 of file store_client.cc.

References sc.

Referenced by noteNews().

◆ 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()

◆ maybeWriteFromDiskToMemory()

void store_client::maybeWriteFromDiskToMemory ( const StoreIOBuffer httpResponsePart)
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()

◆ nextHttpReadOffset()

int64_t store_client::nextHttpReadOffset ( ) const
private

◆ noteCopiedBytes()

void store_client::noteCopiedBytes ( size_t  )
private

◆ noteNews()

◆ 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()

void store_client::operator delete ( void *  address)
inline

Definition at line 71 of file StoreClient.h.

◆ operator new()

void * store_client::operator new ( size_t  size)
inline

Definition at line 71 of file StoreClient.h.

◆ parseHttpHeadersFromDisk()

bool store_client::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()

◆ readFromMemory()

void store_client::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()

◆ readOffset()

int64_t store_client::readOffset ( ) const
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
0means the client wants to read HTTP response headers.
+Nthe response byte that the client wants to read next.
-Nshould not occur.

Definition at line 85 of file StoreClient.h.

References copyInto, and StoreIOBuffer::offset.

Referenced by LowestMemReader::operator()().

◆ scheduleDiskRead()

void store_client::scheduleDiskRead ( )
private

◆ scheduleRead()

void store_client::scheduleRead ( )
private

◆ sendingHttpHeaders()

bool store_client::sendingHttpHeaders ( ) const
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()

◆ skipHttpHeadersFromDisk()

void store_client::skipHttpHeadersFromDisk ( )
private

◆ startSwapin()

bool store_client::startSwapin ( )
private

◆ toCbdata()

void * store_client::toCbdata ( )
inlinenoexcept

Definition at line 71 of file StoreClient.h.

◆ tryParsingHttpHeaders()

bool store_client::tryParsingHttpHeaders ( )
private

Member Data Documentation

◆ _callback

◆ answers

uint64_t store_client::answers
private

Definition at line 181 of file StoreClient.h.

Referenced by answeredOnce(), doCopy(), and finishCallback().

◆ atEof_

bool store_client::atEof_
private

Whether the last successful storeClientCopy() answer was known to contain the last body bytes of the HTTP response

Return values
truerequesting 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

cbdata_type store_client::CBDATA_store_client = CBDATA_UNKNOWN
staticprivate

Definition at line 71 of file StoreClient.h.

◆ copyInto

StoreIOBuffer store_client::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

◆ 

struct { ... } store_client::flags

◆ lastDiskRead

StoreIOBuffer store_client::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

bool store_client::object_ok
private

Definition at line 171 of file StoreClient.h.

Referenced by fail(), finishCallback(), and readHeader().

◆ parsingBuffer

std::optional<Store::ParsingBuffer> store_client::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

int store_client::type
private

Definition at line 170 of file StoreClient.h.

Referenced by getType().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors