MemStore.cc
Go to the documentation of this file.
41 ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice = -1);
75 ShmWriter::ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice):
383 const Ipc::StoreMapSlice &slice = map->readableSlice(update.stale.fileNo, update.stale.splicingPoint);
437 MemStore::updateAnchoredWith(StoreEntry &entry, const sfileno index, const Ipc::StoreMapAnchor &anchor)
514 if (reply.parseTerminatedPrefix(httpHeaderParsingBuffer.c_str(), httpHeaderParsingBuffer.length()))
549 throw TextException(ToSBuf("truncated mem-cached headers; accumulated: ", httpHeaderParsingBuffer.length()), Here());
652 Ipc::StoreMapAnchor *slot = map->openForWriting(reinterpret_cast<const cache_key *>(e.key), index);
708 MemStore::copyToShmSlice(StoreEntry &e, Ipc::StoreMapAnchor &anchor, Ipc::StoreMap::Slice &slice)
Anchor & writeableEntry(const AnchorId anchorId)
writeable anchor for the entry created by openForWriting()
Definition: StoreMap.cc:238
void freeEntryByKey(const cache_key *const key)
Definition: StoreMap.cc:331
ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice=-1)
Definition: MemStore.cc:75
void updateHeaders(StoreEntry *e) override
make stored metadata and HTTP headers the same as in the given entry
Definition: MemStore.cc:342
void closeForWriting(const sfileno fileno)
successfully finish creating or updating the entry at fileno pos
Definition: StoreMap.cc:201
void startAppending(const sfileno fileno)
restrict opened for writing entry to appending operations; allow reads
Definition: StoreMap.cc:192
void append(const char *aBuf, int aSize) override
Appends a c-string to existing packed data.
Definition: MemStore.cc:90
Definition: MemStore.cc:38
bool startCaching(StoreEntry &e)
locks map anchor and preps to store the entry in shared memory
Definition: MemStore.cc:649
static bool Enabled()
whether Squid is correctly configured to use a shared memory cache
Definition: MemStore.h:68
static const auto MapLabel
shared memory segment path to use for MemStore maps
Definition: MemStore.cc:29
void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: MemStore.cc:256
sfileno lastWritingSlice
the last allocate slice for writing a store entry (during copyToShm)
Definition: MemStore.h:106
void set(const StoreEntry &anEntry, const cache_key *aKey=nullptr)
store StoreEntry key and basics for an inode slot
Definition: StoreMap.cc:959
Definition: PageStack.h:108
void create() override
called when the runner should create a new memory segment
Definition: MemStore.cc:1028
SliceId sliceContaining(const sfileno fileno, const uint64_t nth) const
Definition: StoreMap.cc:421
Definition: Segment.h:84
void packHeadersUsingSlowPacker(Packable &p) const
same as packHeadersUsingFastPacker() but assumes that p cannot quickly process small additions
Definition: HttpReply.cc:95
void push(PageId &page)
makes value available as a free page number to future pop() callers
Definition: PageStack.cc:465
static const char * SpaceLabel
shared memory segment path to use for the free slices index
Definition: MemStore.cc:31
Definition: StoreMap.h:28
void updateStats(ReadWriteLockStats &stats) const
adds approximate current stats to the supplied ones
Definition: StoreMap.cc:751
void prepFreeSlice(const SliceId sliceId)
prepare a chain-unaffiliated slice for being added to an entry chain
Definition: StoreMap.cc:413
uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: MemStore.cc:261
static Owner * Init(const SBuf &path, const int slotLimit)
initialize shared memory
Definition: StoreMap.cc:43
Definition: Packable.h:52
std::atomic< uint8_t > writerHalted
whether StoreMap::abortWriting() was called for a read-locked entry
Definition: StoreMap.h:83
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:63
std::atomic< StoreMapSliceId > start
where the chain of StoreEntry slices begins [app]
Definition: StoreMap.h:111
void closeForUpdating(Update &update)
makes updated info available to others, unlocks, and cleans up
Definition: StoreMap.cc:605
const Anchor * openForReading(const cache_key *const key, sfileno &fileno)
opens entry (identified by key) for reading, increments read level
Definition: StoreMap.cc:440
struct Ipc::StoreMapAnchor::Basics basics
void configure(bool beSet)
enables or disables the option; updating to 'configured' state
Definition: YesNoNone.h:53
Definition: StoreIOBuffer.h:15
void copyToShmSlice(StoreEntry &e, Ipc::StoreMapAnchor &anchor, Ipc::StoreMap::Slice &slice)
copies at most one slice worth of local memory to shared memory
Definition: MemStore.cc:708
const Anchor & readableEntry(const AnchorId anchorId) const
readable anchor for the entry created by openForReading()
Definition: StoreMap.cc:245
void NotePageNeed(const int purpose, const int count)
claim the need for a number of pages for a given purpose
Definition: Pages.cc:72
Definition: StoreMap.h:56
void completeWriting(StoreEntry &e)
all data has been received; there will be no more write() calls
Definition: MemStore.cc:886
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:1929
static const char * ExtrasLabel
shared memory segment path to use for IDs of shared pages with slice data
Definition: MemStore.cc:33
DefineRunnerRegistrator(MemStoreRr)
bool set() const
true if and only if both critical components have been initialized
Definition: Page.h:29
void closeForReading(const sfileno fileno)
closes open entry after reading, decrements read level
Definition: StoreMap.cc:497
bool hasMemStore() const
whether there is a corresponding locked shared memory table entry
Definition: Store.h:212
struct SquidConfig::@95 Store
uint64_t currentCount() const override
the total number of objects stored right now
Definition: MemStore.cc:280
void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override
adjust slice-linked state before a locked Readable slice is erased
Definition: MemStore.cc:825
FREE destroyStoreEntry
std::atomic< uint64_t > swap_file_sz
Definition: StoreMap.h:105
void PutPage(PageId &page)
makes identified page available as a free page to future GetPage() callers
Definition: Pages.cc:41
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
Definition: TextException.cc:88
Aggregates information required for updating entry metadata and headers.
Definition: StoreMap.h:181
Anchor * openForWriting(const cache_key *const key, sfileno &fileno)
Definition: StoreMap.cc:141
void anchorEntry(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
anchors StoreEntry to an already locked map entry
Definition: MemStore.cc:446
Definition: StoreMap.h:121
sfileno reserveSapForWriting(Ipc::Mem::PageId &page)
finds a slot and a free page to fill or throws
Definition: MemStore.cc:786
Ipc::StoreMapSliceId lastSlice
the slot keeping the last byte of the appended content (at least)
Definition: MemStore.cc:55
bool pop(PageId &page)
sets value and returns true unless no free page numbers are found
Definition: PageStack.cc:442
Definition: MemObject.h:33
void exportInto(StoreEntry &) const
load StoreEntry basics that were previously stored with set()
Definition: StoreMap.cc:979
StoreMapSliceId splicingPoint
the last slice in the chain still containing metadata/headers
Definition: StoreMap.h:198
const Slice & readableSlice(const AnchorId anchorId, const SliceId sliceId) const
readable slice within an entry chain opened by openForReading()
Definition: StoreMap.cc:230
Definition: Store.h:37
char * PagePointer(const PageId &page)
converts page handler into a temporary writeable shared memory pointer
Definition: Pages.cc:48
void updateHeadersOrThrow(Ipc::StoreMapUpdate &update)
Definition: MemStore.cc:362
int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Controller.cc:181
size_t PageLimit()
the total number of shared memory pages that can be in use at any time
Definition: Pages.cc:55
bool copyFromShm(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
copies the entire entry from shared to local memory
Definition: MemStore.cc:471
bool GetPage(const PageId::Purpose purpose, PageId &page)
sets page ID and returns true unless no free pages are found
Definition: Pages.cc:34
PageStack construction and SharedMemorySize calculation parameters.
Definition: PageStack.h:123
void write(StoreEntry &e)
copy non-shared entry data of the being-cached entry to our cache
Definition: MemStore.cc:847
void copyFromShmSlice(StoreEntry &, const StoreIOBuffer &)
imports one shared memory slice into local memory
Definition: MemStore.cc:567
static int64_t EntryLimit()
calculates maximum number of entries we need to store and map
Definition: MemStore.cc:958
Definition: MemStore.cc:971
bool purgeOne()
either finds and frees an entry with at least 1 slice or returns false
Definition: StoreMap.cc:702
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:195
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:63
bool createFull
whether a newly created PageStack should be prefilled with PageIds
Definition: PageStack.h:130
Ipc::StoreMap::Slice & nextAppendableSlice(const sfileno entryIndex, sfileno &sliceOffset)
Definition: MemStore.cc:739
bool updateAnchoredWith(StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &)
updates Transients entry after its anchor has been located
Definition: MemStore.cc:437
void abortWriting(const sfileno fileno)
stop writing the entry, freeing its slot for others to use if possible
Definition: StoreMap.cc:252
Ipc::Mem::PageId pageForSlice(Ipc::StoreMapSliceId sliceId)
safely returns a previously allocated memory page for the given entry slice
Definition: MemStore.cc:775
Definition: MemStore.h:29
size_t PagesAvailable()
approximate total number of shared memory pages we can allocate now
Definition: Pages.h:47
size_t PageSize()
returns page size in bytes; all pages are assumed to be the same size
Definition: Pages.cc:28
static void Broadcast(const StoreEntry &e, const bool includingThisWorker=false)
notify other workers about changes in entry state (e.g., new data)
Definition: CollapsedForwarding.cc:70
bool hasParsedReplyHeader() const
whether this entry has access to [deserialized] [HTTP] response headers
Definition: store.cc:231
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:696
void copyToShmSlice(Ipc::StoreMap::Slice &slice)
copies at most one slice worth of buffer to shared memory
Definition: MemStore.cc:136
void disconnect(StoreEntry &e)
called when the entry is about to forget its association with mem cache
Definition: MemStore.cc:930
void storeWriterDone()
called when a store writer ends its work (successfully or not)
Definition: store.cc:1808
void abortUpdating(Update &update)
undoes partial update, unlocks, and cleans up
Definition: StoreMap.cc:269
bool openForUpdating(Update &update, sfileno fileNoHint)
finds and locks the Update entry for an exclusive metadata update
Definition: StoreMap.cc:523
void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: MemStore.cc:292
aggregates anchor and slice owners for Init() caller convenience
Definition: StoreMap.h:232
int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: MemStore.cc:286
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
Slice & writeableSlice(const AnchorId anchorId, const SliceId sliceId)
writeable slice within an entry chain created by openForWriting()
Definition: StoreMap.cc:222
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