Public Member Functions | |
ShmWriter (MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice=-1) | |
void | append (const char *aBuf, int aSize) override |
Appends a c-string to existing packed data. More... | |
void | vappendf (const char *fmt, va_list ap) override |
void | appendf (const char *fmt,...) PRINTF_FORMAT_ARG2 |
Append operation with printf-style arguments. More... | |
virtual void | buffer () |
virtual void | flush () |
Public Attributes | |
StoreEntry * | entry |
the entry being updated More... | |
Ipc::StoreMapSliceId | firstSlice |
Ipc::StoreMapSliceId | lastSlice |
the slot keeping the last byte of the appended content (at least) More... | |
uint64_t | totalWritten |
cumulative number of bytes appended so far More... | |
Protected Member Functions | |
void | copyToShm () |
copies the entire buffer to shared memory More... | |
void | copyToShmSlice (Ipc::StoreMap::Slice &slice) |
copies at most one slice worth of buffer to shared memory More... | |
Private Attributes | |
MemStore & | store |
const sfileno | fileNo |
const char * | buf |
content being appended now More... | |
int | bufSize |
buf size More... | |
int | bufWritten |
buf bytes appended so far More... | |
Detailed Description
Packs to shared memory, allocating new slots/pages as needed. Requires an Ipc::StoreMapAnchor locked for writing.
Definition at line 37 of file MemStore.cc.
Constructor & Destructor Documentation
◆ ShmWriter()
ShmWriter::ShmWriter | ( | MemStore & | aStore, |
StoreEntry * | anEntry, | ||
const sfileno | aFileNo, | ||
Ipc::StoreMapSliceId | aFirstSlice = -1 |
||
) |
Definition at line 74 of file MemStore.cc.
Member Function Documentation
◆ append()
|
overridevirtual |
Implements Packable.
Definition at line 89 of file MemStore.cc.
References buf, bufSize, bufWritten, copyToShm(), and Must.
Referenced by MemStore::updateHeadersOrThrow(), and vappendf().
◆ appendf()
|
inlineinherited |
Definition at line 61 of file Packable.h.
References Packable::vappendf().
Referenced by Ftp::Server::acceptDataConnection(), aclParseAccessLine(), aclParseAclList(), Format::Format::assemble(), HttpStateData::buildRequestPrefix(), clientPackRangeHdr(), clientPackTermBound(), ErrorState::compileLegacyCode(), ErrorState::Dump(), EventScheduler::dump(), dump_cachemgrpasswd(), store_client::dumpStats(), Adaptation::Icap::ModXact::encapsulateHead(), Adaptation::Icap::Xaction::fillDoneStatus(), Adaptation::Icap::ModXact::fillDoneStatus(), Adaptation::Icap::Xaction::fillPendingStatus(), Adaptation::Icap::ModXact::fillPendingStatus(), HttpStateData::getMoreRequestBody(), Ftp::Server::handleEpsvReply(), Ftp::Server::handlePasvReply(), helperDispatch(), httpHdrContRangePackInto(), httpHdrRangeRespSpecPackInto(), internalRemoteUri(), Adaptation::Icap::ModXact::makeAllowHeader(), Adaptation::Icap::OptXact::makeRequest(), Adaptation::Icap::ModXact::makeRequestHeaders(), Adaptation::Icap::ModXact::makeUsernameHeader(), memBufReport(), munge_menu_line(), munge_other_line(), Adaptation::Icap::ModXact::openChunk(), HttpRequest::pack(), Http::Stream::packChunk(), HttpRequest::packFirstLineInto(), Http::StatusLine::packInto(), HttpHdrCc::packInto(), HttpHdrScTarget::packInto(), HttpHdrRangeSpec::packInto(), Helper::Client::packStatsInto(), Acl::AllOf::parse(), Ftp::PrintReply(), Ftp::Client::sendEprt(), Ftp::Client::sendPassive(), ExternalACLLookup::Start(), Ident::Start(), MemObject::stat(), statStoreEntry(), AsyncJob::status(), BodyPipe::status(), Adaptation::Ecap::XactionRep::status(), Adaptation::Icap::ServiceRep::status(), Adaptation::Icap::Xaction::status(), Http::Tunneler::status(), Comm::TcpAcceptor::status(), Ipc::Inquirer::status(), Security::PeerConnector::status(), wordlistCat(), Ftp::Server::writeCustomReply(), Ftp::Server::writeEarlyReply(), Ftp::Server::writeErrorReply(), and Http::Tunneler::writeRequest().
◆ buffer()
|
inlinevirtualinherited |
start buffering appends (if relevant)
Indicates that a number of small appends are about to follow so would be detrimental to trigger expensive activity on each.
Reimplemented in StoreEntry, and CapturingStoreEntry.
Definition at line 88 of file Packable.h.
◆ copyToShm()
|
protected |
Definition at line 117 of file MemStore.cc.
References bufSize, bufWritten, copyToShmSlice(), debugs, entry, fileNo, firstSlice, lastSlice, Must, MemStore::nextAppendableSlice(), store, and totalWritten.
Referenced by append().
◆ copyToShmSlice()
|
protected |
Definition at line 135 of file MemStore.cc.
References buf, bufSize, bufWritten, debugs, entry, lastSlice, min(), Must, MemStore::pageForSlice(), Ipc::Mem::PagePointer(), Ipc::Mem::PageSize(), Ipc::StoreMapSlice::size, store, and totalWritten.
Referenced by copyToShm().
◆ flush()
|
inlinevirtualinherited |
perform a buffer flush (if relevant)
Used by code such as PackableStream, that assumes the Packable leads to some form of output buffer.
Reimplemented in StoreEntry, and CapturingStoreEntry.
Definition at line 95 of file Packable.h.
◆ vappendf()
|
overridevirtual |
Append operation, with vsprintf(3)-style arguments.
- Note
- arguments may be evaluated more than once, be careful of side-effects
XXX: This method either should not exist or should not be virtual. Kids should not be forced to re-implement vappendf() logic. That logic should be implemented once, using other [Packable] APIs. Packable is not about providing a printf(3) service. Packable is about writing opaque data to various custom destinations.
Implements Packable.
Definition at line 105 of file MemStore.cc.
References append(), SBuf::length(), SBuf::rawContent(), and SBuf::vappendf().
Member Data Documentation
◆ buf
|
private |
Definition at line 67 of file MemStore.cc.
Referenced by append(), and copyToShmSlice().
◆ bufSize
|
private |
Definition at line 68 of file MemStore.cc.
Referenced by append(), copyToShm(), and copyToShmSlice().
◆ bufWritten
|
private |
Definition at line 69 of file MemStore.cc.
Referenced by append(), copyToShm(), and copyToShmSlice().
◆ entry
StoreEntry* ShmWriter::entry |
Definition at line 47 of file MemStore.cc.
Referenced by ShmWriter(), copyToShm(), and copyToShmSlice().
◆ fileNo
|
private |
Definition at line 64 of file MemStore.cc.
Referenced by copyToShm().
◆ firstSlice
Ipc::StoreMapSliceId ShmWriter::firstSlice |
the slot keeping the first byte of the appended content (at least) either set via constructor parameter or allocated by the first append
Definition at line 51 of file MemStore.cc.
Referenced by copyToShm().
◆ lastSlice
Ipc::StoreMapSliceId ShmWriter::lastSlice |
Definition at line 54 of file MemStore.cc.
Referenced by copyToShm(), copyToShmSlice(), and MemStore::updateHeadersOrThrow().
◆ store
|
private |
Definition at line 63 of file MemStore.cc.
Referenced by copyToShm(), and copyToShmSlice().
◆ totalWritten
uint64_t ShmWriter::totalWritten |
Definition at line 56 of file MemStore.cc.
Referenced by copyToShm(), copyToShmSlice(), and MemStore::updateHeadersOrThrow().
The documentation for this class was generated from the following file:
- src/MemStore.cc