MemStore.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 20 Memory Cache */
10 
11 #include "squid.h"
12 #include "base/RunnersRegistry.h"
13 #include "CollapsedForwarding.h"
14 #include "HttpReply.h"
15 #include "ipc/mem/Page.h"
16 #include "ipc/mem/Pages.h"
17 #include "MemObject.h"
18 #include "MemStore.h"
19 #include "mime_header.h"
20 #include "SquidConfig.h"
21 #include "SquidMath.h"
22 #include "StoreStats.h"
23 #include "tools.h"
24 
26 static const SBuf MapLabel("cache_mem_map");
28 static const char *SpaceLabel = "cache_mem_space";
30 static const char *ExtrasLabel = "cache_mem_ex";
31 // TODO: sync with Rock::SwapDir::*Path()
32 
33 // We store free slot IDs (i.e., "space") as Page objects so that we can use
34 // Ipc::Mem::PageStack. Pages require pool IDs. The value here is not really
35 // used except for a positivity test. A unique value is handy for debugging.
36 static const uint32_t SpacePoolId = 510716;
37 
40 class ShmWriter: public Packable
41 {
42 public:
43  ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice = -1);
44 
45  /* Packable API */
46  virtual void append(const char *aBuf, int aSize) override;
47  virtual void vappendf(const char *fmt, va_list ap) override;
48 
49 public:
51 
55 
58 
59  uint64_t totalWritten;
60 
61 protected:
62  void copyToShm();
64 
65 private:
67  const sfileno fileNo;
68 
69  /* set by (and only valid during) append calls */
70  const char *buf;
71  int bufSize;
72  int bufWritten;
73 };
74 
75 /* ShmWriter */
76 
77 ShmWriter::ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice):
78  entry(anEntry),
79  firstSlice(aFirstSlice),
80  lastSlice(firstSlice),
81  totalWritten(0),
82  store(aStore),
83  fileNo(aFileNo),
84  buf(nullptr),
85  bufSize(0),
86  bufWritten(0)
87 {
88  Must(entry);
89 }
90 
91 void
92 ShmWriter::append(const char *aBuf, int aBufSize)
93 {
94  Must(!buf);
95  buf = aBuf;
96  bufSize = aBufSize;
97  if (bufSize) {
98  Must(buf);
99  bufWritten = 0;
100  copyToShm();
101  }
102  buf = nullptr;
103  bufSize = 0;
104  bufWritten = 0;
105 }
106 
107 void
108 ShmWriter::vappendf(const char *fmt, va_list ap)
109 {
110  SBuf vaBuf;
111 #if defined(VA_COPY)
112  va_list apCopy;
113  VA_COPY(apCopy, ap);
114  vaBuf.vappendf(fmt, apCopy);
115  va_end(apCopy);
116 #else
117  vaBuf.vappendf(fmt, ap);
118 #endif
119  append(vaBuf.rawContent(), vaBuf.length());
120 }
121 
123 void
125 {
126  Must(bufSize > 0); // do not use up shared memory pages for nothing
127  Must(firstSlice < 0 || lastSlice >= 0);
128 
129  // fill, skip slices that are already full
130  while (bufWritten < bufSize) {
132  if (firstSlice < 0)
134  copyToShmSlice(slice);
135  }
136 
137  debugs(20, 7, "stored " << bufWritten << '/' << totalWritten << " header bytes of " << *entry);
138 }
139 
141 void
143 {
145  debugs(20, 7, "entry " << *entry << " slice " << lastSlice << " has " <<
146  page);
147 
148  Must(bufWritten <= bufSize);
149  const int64_t writingDebt = bufSize - bufWritten;
150  const int64_t pageSize = Ipc::Mem::PageSize();
151  const int64_t sliceOffset = totalWritten % pageSize;
152  const int64_t copySize = std::min(writingDebt, pageSize - sliceOffset);
153  memcpy(static_cast<char*>(PagePointer(page)) + sliceOffset, buf + bufWritten,
154  copySize);
155 
156  debugs(20, 7, "copied " << slice.size << '+' << copySize << " bytes of " <<
157  entry << " from " << sliceOffset << " in " << page);
158 
159  slice.size += copySize;
160  bufWritten += copySize;
161  totalWritten += copySize;
162  // fresh anchor.basics.swap_file_sz is already set [to the stale value]
163 
164  // either we wrote everything or we filled the entire slice
165  Must(bufWritten == bufSize || sliceOffset + copySize == pageSize);
166 }
167 
168 /* MemStore */
169 
170 MemStore::MemStore(): map(NULL), lastWritingSlice(-1)
171 {
172 }
173 
175 {
176  delete map;
177 }
178 
179 void
181 {
182  const int64_t entryLimit = EntryLimit();
183  if (entryLimit <= 0)
184  return; // no memory cache configured or a misconfiguration
185 
186  // check compatibility with the disk cache, if any
187  if (Config.cacheSwap.n_configured > 0) {
188  const int64_t diskMaxSize = Store::Root().maxObjectSize();
189  const int64_t memMaxSize = maxObjectSize();
190  if (diskMaxSize == -1) {
191  debugs(20, DBG_IMPORTANT, "WARNING: disk-cache maximum object size "
192  "is unlimited but mem-cache maximum object size is " <<
193  memMaxSize / 1024.0 << " KB");
194  } else if (diskMaxSize > memMaxSize) {
195  debugs(20, DBG_IMPORTANT, "WARNING: disk-cache maximum object size "
196  "is too large for mem-cache: " <<
197  diskMaxSize / 1024.0 << " KB > " <<
198  memMaxSize / 1024.0 << " KB");
199  }
200  }
201 
204 
205  Must(!map);
206  map = new MemStoreMap(MapLabel);
207  map->cleaner = this;
208 }
209 
210 void
212 {
213  const size_t pageSize = Ipc::Mem::PageSize();
214 
215  stats.mem.shared = true;
216  stats.mem.capacity =
218  stats.mem.size =
220  stats.mem.count = currentCount();
221 }
222 
223 void
225 {
226  storeAppendPrintf(&e, "\n\nShared Memory Cache\n");
227 
228  storeAppendPrintf(&e, "Maximum Size: %.0f KB\n", maxSize()/1024.0);
229  storeAppendPrintf(&e, "Current Size: %.2f KB %.2f%%\n",
230  currentSize() / 1024.0,
232 
233  if (map) {
234  const int entryLimit = map->entryLimit();
235  const int slotLimit = map->sliceLimit();
236  storeAppendPrintf(&e, "Maximum entries: %9d\n", entryLimit);
237  if (entryLimit > 0) {
238  storeAppendPrintf(&e, "Current entries: %" PRId64 " %.2f%%\n",
239  currentCount(), (100.0 * currentCount() / entryLimit));
240  }
241 
242  storeAppendPrintf(&e, "Maximum slots: %9d\n", slotLimit);
243  if (slotLimit > 0) {
244  const unsigned int slotsFree =
246  if (slotsFree <= static_cast<const unsigned int>(slotLimit)) {
247  const int usedSlots = slotLimit - static_cast<const int>(slotsFree);
248  storeAppendPrintf(&e, "Used slots: %9d %.2f%%\n",
249  usedSlots, (100.0 * usedSlots / slotLimit));
250  }
251 
252  if (slotLimit < 100) { // XXX: otherwise too expensive to count
254  map->updateStats(stats);
255  stats.dump(e);
256  }
257  }
258  }
259 }
260 
261 void
263 {
264 }
265 
266 uint64_t
268 {
269  return 0; // XXX: irrelevant, but Store parent forces us to implement this
270 }
271 
272 uint64_t
274 {
275  return Config.memMaxSize;
276 }
277 
278 uint64_t
280 {
283 }
284 
285 uint64_t
287 {
288  return map ? map->entryCount() : 0;
289 }
290 
291 int64_t
293 {
295 }
296 
297 void
299 {
300 }
301 
302 bool
304 {
305  // no need to keep e in the global store_table for us; we have our own map
306  return false;
307 }
308 
309 StoreEntry *
311 {
312  if (!map)
313  return NULL;
314 
315  sfileno index;
316  const Ipc::StoreMapAnchor *const slot = map->openForReading(key, index);
317  if (!slot)
318  return NULL;
319 
320  // create a brand new store entry and initialize it with stored info
321  StoreEntry *e = new StoreEntry();
322 
323  // XXX: We do not know the URLs yet, only the key, but we need to parse and
324  // store the response for the Root().find() callers to be happy because they
325  // expect IN_MEMORY entries to already have the response headers and body.
326  e->createMemObject();
327 
328  anchorEntry(*e, index, *slot);
329 
330  const bool copied = copyFromShm(*e, index, *slot);
331 
332  if (copied)
333  return e;
334 
335  debugs(20, 3, "failed for " << *e);
336  map->freeEntry(index); // do not let others into the same trap
337  destroyStoreEntry(static_cast<hash_link *>(e));
338  return NULL;
339 }
340 
341 void
343 {
344  if (!map)
345  return;
346 
347  Ipc::StoreMapUpdate update(updatedE);
348  assert(updatedE);
349  assert(updatedE->mem_obj);
350  if (!map->openForUpdating(update, updatedE->mem_obj->memCache.index))
351  return;
352 
353  try {
354  updateHeadersOrThrow(update);
355  } catch (const std::exception &ex) {
356  debugs(20, 2, "error starting to update entry " << *updatedE << ": " << ex.what());
357  map->abortUpdating(update);
358  }
359 }
360 
361 void
363 {
364  // our +/- hdr_sz math below does not work if the chains differ [in size]
366 
367  const HttpReply *rawReply = update.entry->getReply();
368  Must(rawReply);
369  const HttpReply &reply = *rawReply;
370  const uint64_t staleHdrSz = reply.hdr_sz;
371  debugs(20, 7, "stale hdr_sz: " << staleHdrSz);
372 
373  /* we will need to copy same-slice payload after the stored headers later */
374  Must(staleHdrSz > 0);
375  update.stale.splicingPoint = map->sliceContaining(update.stale.fileNo, staleHdrSz);
376  Must(update.stale.splicingPoint >= 0);
377  Must(update.stale.anchor->basics.swap_file_sz >= staleHdrSz);
378 
379  Must(update.stale.anchor);
380  ShmWriter writer(*this, update.entry, update.fresh.fileNo);
381  reply.packHeadersInto(&writer);
382  const uint64_t freshHdrSz = writer.totalWritten;
383  debugs(20, 7, "fresh hdr_sz: " << freshHdrSz << " diff: " << (freshHdrSz - staleHdrSz));
384 
385  /* copy same-slice payload remaining after the stored headers */
386  const Ipc::StoreMapSlice &slice = map->readableSlice(update.stale.fileNo, update.stale.splicingPoint);
387  const Ipc::StoreMapSlice::Size sliceCapacity = Ipc::Mem::PageSize();
388  const Ipc::StoreMapSlice::Size headersInLastSlice = staleHdrSz % sliceCapacity;
389  Must(headersInLastSlice > 0); // or sliceContaining() would have stopped earlier
390  Must(slice.size >= headersInLastSlice);
391  const Ipc::StoreMapSlice::Size payloadInLastSlice = slice.size - headersInLastSlice;
392  const MemStoreMapExtras::Item &extra = extras->items[update.stale.splicingPoint];
393  char *page = static_cast<char*>(PagePointer(extra.page));
394  debugs(20, 5, "appending same-slice payload: " << payloadInLastSlice);
395  writer.append(page + headersInLastSlice, payloadInLastSlice);
396  update.fresh.splicingPoint = writer.lastSlice;
397 
398  update.fresh.anchor->basics.swap_file_sz -= staleHdrSz;
399  update.fresh.anchor->basics.swap_file_sz += freshHdrSz;
400 
401  map->closeForUpdating(update);
402 }
403 
404 bool
405 MemStore::anchorToCache(StoreEntry &entry, bool &inSync)
406 {
407  if (!map)
408  return false;
409 
410  sfileno index;
411  const Ipc::StoreMapAnchor *const slot = map->openForReading(
412  reinterpret_cast<cache_key*>(entry.key), index);
413  if (!slot)
414  return false;
415 
416  anchorEntry(entry, index, *slot);
417  inSync = updateAnchoredWith(entry, index, *slot);
418  return true; // even if inSync is false
419 }
420 
421 bool
423 {
424  if (!map)
425  return false;
426 
427  assert(entry.mem_obj);
428  assert(entry.hasMemStore());
429  const sfileno index = entry.mem_obj->memCache.index;
430  const Ipc::StoreMapAnchor &anchor = map->readableEntry(index);
431  return updateAnchoredWith(entry, index, anchor);
432 }
433 
435 bool
437 {
438  entry.swap_file_sz = anchor.basics.swap_file_sz;
439  const bool copied = copyFromShm(entry, index, anchor);
440  return copied;
441 }
442 
444 void
446 {
447  assert(!e.hasDisk()); // no conflict with disk entry basics
448  anchor.exportInto(e);
449 
450  assert(e.mem_obj);
451  if (anchor.complete()) {
455  } else {
457  assert(e.mem_obj->object_sz < 0);
459  }
460 
462 
464  mc.index = index;
466 }
467 
469 bool
471 {
472  debugs(20, 7, "mem-loading entry " << index << " from " << anchor.start);
473  assert(e.mem_obj);
474 
475  // emulate the usual Store code but w/o inapplicable checks and callbacks:
476 
477  Ipc::StoreMapSliceId sid = anchor.start; // optimize: remember the last sid
478  bool wasEof = anchor.complete() && sid < 0;
479  int64_t sliceOffset = 0;
480  while (sid >= 0) {
481  const Ipc::StoreMapSlice &slice = map->readableSlice(index, sid);
482  // slice state may change during copying; take snapshots now
483  wasEof = anchor.complete() && slice.next < 0;
484  const Ipc::StoreMapSlice::Size wasSize = slice.size;
485 
486  debugs(20, 9, "entry " << index << " slice " << sid << " eof " <<
487  wasEof << " wasSize " << wasSize << " <= " <<
488  anchor.basics.swap_file_sz << " sliceOffset " << sliceOffset <<
489  " mem.endOffset " << e.mem_obj->endOffset());
490 
491  if (e.mem_obj->endOffset() < sliceOffset + wasSize) {
492  // size of the slice data that we already copied
493  const size_t prefixSize = e.mem_obj->endOffset() - sliceOffset;
494  assert(prefixSize <= wasSize);
495 
496  const MemStoreMapExtras::Item &extra = extras->items[sid];
497 
498  char *page = static_cast<char*>(PagePointer(extra.page));
499  const StoreIOBuffer sliceBuf(wasSize - prefixSize,
500  e.mem_obj->endOffset(),
501  page + prefixSize);
502  if (!copyFromShmSlice(e, sliceBuf, wasEof))
503  return false;
504  debugs(20, 9, "entry " << index << " copied slice " << sid <<
505  " from " << extra.page << '+' << prefixSize);
506  }
507  // else skip a [possibly incomplete] slice that we copied earlier
508 
509  // careful: the slice may have grown _and_ gotten the next slice ID!
510  if (slice.next >= 0) {
511  assert(!wasEof);
512  // here we know that slice.size may not change any more
513  if (wasSize >= slice.size) { // did not grow since we started copying
514  sliceOffset += wasSize;
515  sid = slice.next;
516  }
517  } else if (wasSize >= slice.size) { // did not grow
518  break;
519  }
520  }
521 
522  if (!wasEof) {
523  debugs(20, 7, "mem-loaded " << e.mem_obj->endOffset() << '/' <<
524  anchor.basics.swap_file_sz << " bytes of " << e);
525  return true;
526  }
527 
528  debugs(20, 7, "mem-loaded all " << e.mem_obj->object_sz << '/' <<
529  anchor.basics.swap_file_sz << " bytes of " << e);
530 
531  // from StoreEntry::complete()
535 
536  assert(e.mem_obj->object_sz >= 0);
537  assert(static_cast<uint64_t>(e.mem_obj->object_sz) == anchor.basics.swap_file_sz);
538  // would be nice to call validLength() here, but it needs e.key
539 
540  // we read the entire response into the local memory; no more need to lock
541  disconnect(e);
542  return true;
543 }
544 
546 bool
548 {
549  debugs(20, 7, "buf: " << buf.offset << " + " << buf.length);
550 
551  // from store_client::readBody()
552  // parse headers if needed; they might span multiple slices!
553  HttpReply *rep = (HttpReply *)e.getReply();
554  if (rep->pstate < Http::Message::psParsed) {
555  // XXX: have to copy because httpMsgParseStep() requires 0-termination
556  MemBuf mb;
557  mb.init(buf.length+1, buf.length+1);
558  mb.append(buf.data, buf.length);
559  mb.terminate();
560  const int result = rep->httpMsgParseStep(mb.buf, buf.length, eof);
561  if (result > 0) {
564  } else if (result < 0) {
565  debugs(20, DBG_IMPORTANT, "Corrupted mem-cached headers: " << e);
566  return false;
567  } else { // more slices are needed
568  assert(!eof);
569  }
570  }
571  debugs(20, 7, "rep pstate: " << rep->pstate);
572 
573  // local memory stores both headers and body so copy regardless of pstate
574  const int64_t offBefore = e.mem_obj->endOffset();
575  assert(e.mem_obj->data_hdr.write(buf)); // from MemObject::write()
576  const int64_t offAfter = e.mem_obj->endOffset();
577  // expect to write the entire buf because StoreEntry::write() never fails
578  assert(offAfter >= 0 && offBefore <= offAfter &&
579  static_cast<size_t>(offAfter - offBefore) == buf.length);
580  return true;
581 }
582 
584 bool
586 {
587  if (e.mem_status == IN_MEMORY) {
588  debugs(20, 5, "already loaded from mem-cache: " << e);
589  return false;
590  }
591 
592  if (e.mem_obj && e.mem_obj->memCache.offset > 0) {
593  debugs(20, 5, "already written to mem-cache: " << e);
594  return false;
595  }
596 
597  if (!e.memoryCachable()) {
598  debugs(20, 7, HERE << "Not memory cachable: " << e);
599  return false; // will not cache due to entry state or properties
600  }
601 
602  assert(e.mem_obj);
603 
604  if (!e.mem_obj->vary_headers.isEmpty()) {
605  // XXX: We must store/load SerialisedMetaData to cache Vary in RAM
606  debugs(20, 5, "Vary not yet supported: " << e.mem_obj->vary_headers);
607  return false;
608  }
609 
610  const int64_t expectedSize = e.mem_obj->expectedReplySize(); // may be < 0
611  const int64_t loadedSize = e.mem_obj->endOffset();
612  const int64_t ramSize = max(loadedSize, expectedSize);
613  if (ramSize > maxObjectSize()) {
614  debugs(20, 5, HERE << "Too big max(" <<
615  loadedSize << ", " << expectedSize << "): " << e);
616  return false; // will not cache due to cachable entry size limits
617  }
618 
619  if (!e.mem_obj->isContiguous()) {
620  debugs(20, 5, "not contiguous");
621  return false;
622  }
623 
624  if (!map) {
625  debugs(20, 5, HERE << "No map to mem-cache " << e);
626  return false;
627  }
628 
629  if (EBIT_TEST(e.flags, ENTRY_SPECIAL)) {
630  debugs(20, 5, "Not mem-caching ENTRY_SPECIAL " << e);
631  return false;
632  }
633 
634  return true;
635 }
636 
638 bool
640 {
641  sfileno index = 0;
642  Ipc::StoreMapAnchor *slot = map->openForWriting(reinterpret_cast<const cache_key *>(e.key), index);
643  if (!slot) {
644  debugs(20, 5, HERE << "No room in mem-cache map to index " << e);
645  return false;
646  }
647 
648  assert(e.mem_obj);
649  e.mem_obj->memCache.index = index;
651  slot->set(e);
652  // Do not allow others to feed off an unknown-size entry because we will
653  // stop swapping it out if it grows too large.
654  if (e.mem_obj->expectedReplySize() >= 0)
655  map->startAppending(index);
656  e.memOutDecision(true);
657  return true;
658 }
659 
661 void
663 {
664  // prevents remote readers from getting ENTRY_FWD_HDR_WAIT entries and
665  // not knowing when the wait is over
667  debugs(20, 5, "postponing copying " << e << " for ENTRY_FWD_HDR_WAIT");
668  return;
669  }
670 
671  assert(map);
672  assert(e.mem_obj);
673 
674  const int64_t eSize = e.mem_obj->endOffset();
675  if (e.mem_obj->memCache.offset >= eSize) {
676  debugs(20, 5, "postponing copying " << e << " for lack of news: " <<
677  e.mem_obj->memCache.offset << " >= " << eSize);
678  return; // nothing to do (yet)
679  }
680 
681  // throw if an accepted unknown-size entry grew too big or max-size changed
682  Must(eSize <= maxObjectSize());
683 
684  const int32_t index = e.mem_obj->memCache.index;
685  assert(index >= 0);
686  Ipc::StoreMapAnchor &anchor = map->writeableEntry(index);
687  lastWritingSlice = anchor.start;
688 
689  // fill, skip slices that are already full
690  // Optimize: remember lastWritingSlice in e.mem_obj
691  while (e.mem_obj->memCache.offset < eSize) {
694  if (anchor.start < 0)
695  anchor.start = lastWritingSlice;
696  copyToShmSlice(e, anchor, slice);
697  }
698 
699  debugs(20, 7, "mem-cached available " << eSize << " bytes of " << e);
700 }
701 
703 void
705 {
707  debugs(20, 7, "entry " << e << " slice " << lastWritingSlice << " has " <<
708  page);
709 
710  const int64_t bufSize = Ipc::Mem::PageSize();
711  const int64_t sliceOffset = e.mem_obj->memCache.offset % bufSize;
712  StoreIOBuffer sharedSpace(bufSize - sliceOffset, e.mem_obj->memCache.offset,
713  static_cast<char*>(PagePointer(page)) + sliceOffset);
714 
715  // check that we kept everything or purge incomplete/sparse cached entry
716  const ssize_t copied = e.mem_obj->data_hdr.copy(sharedSpace);
717  if (copied <= 0) {
718  debugs(20, 2, "Failed to mem-cache " << (bufSize - sliceOffset) <<
719  " bytes of " << e << " from " << e.mem_obj->memCache.offset <<
720  " in " << page);
721  throw TexcHere("data_hdr.copy failure");
722  }
723 
724  debugs(20, 7, "mem-cached " << copied << " bytes of " << e <<
725  " from " << e.mem_obj->memCache.offset << " in " << page);
726 
727  slice.size += copied;
728  e.mem_obj->memCache.offset += copied;
730 }
731 
735 MemStore::nextAppendableSlice(const sfileno fileNo, sfileno &sliceOffset)
736 {
737  // allocate the very first slot for the entry if needed
738  if (sliceOffset < 0) {
739  Ipc::StoreMapAnchor &anchor = map->writeableEntry(fileNo);
740  Must(anchor.start < 0);
741  Ipc::Mem::PageId page;
742  sliceOffset = reserveSapForWriting(page); // throws
743  extras->items[sliceOffset].page = page;
744  anchor.start = sliceOffset;
745  }
746 
747  const size_t sliceCapacity = Ipc::Mem::PageSize();
748  do {
749  Ipc::StoreMap::Slice &slice = map->writeableSlice(fileNo, sliceOffset);
750 
751  if (slice.size >= sliceCapacity) {
752  if (slice.next >= 0) {
753  sliceOffset = slice.next;
754  continue;
755  }
756 
757  Ipc::Mem::PageId page;
758  slice.next = sliceOffset = reserveSapForWriting(page);
759  extras->items[sliceOffset].page = page;
760  debugs(20, 7, "entry " << fileNo << " new slice: " << sliceOffset);
761  continue; // to get and return the slice at the new sliceOffset
762  }
763 
764  return slice;
765  } while (true);
766  /* not reached */
767 }
768 
772 {
773  Must(extras);
774  Must(sliceId >= 0);
775  Ipc::Mem::PageId page = extras->items[sliceId].page;
776  Must(page);
777  return page;
778 }
779 
781 sfileno
783 {
784  Ipc::Mem::PageId slot;
785  if (freeSlots->pop(slot)) {
786  debugs(20, 5, "got a previously free slot: " << slot);
787 
789  debugs(20, 5, "and got a previously free page: " << page);
790  return slot.number - 1;
791  } else {
792  debugs(20, 3, "but there is no free page, returning " << slot);
793  freeSlots->push(slot);
794  }
795  }
796 
797  // catch free slots delivered to noteFreeMapSlice()
798  assert(!waitingFor);
799  waitingFor.slot = &slot;
800  waitingFor.page = &page;
801  if (map->purgeOne()) {
802  assert(!waitingFor); // noteFreeMapSlice() should have cleared it
803  assert(slot.set());
804  assert(page.set());
805  debugs(20, 5, "got previously busy " << slot << " and " << page);
806  return slot.number - 1;
807  }
808  assert(waitingFor.slot == &slot && waitingFor.page == &page);
809  waitingFor.slot = NULL;
810  waitingFor.page = NULL;
811 
812  debugs(47, 3, "cannot get a slice; entries: " << map->entryCount());
813  throw TexcHere("ran out of mem-cache slots");
814 }
815 
816 void
818 {
819  Ipc::Mem::PageId &pageId = extras->items[sliceId].page;
820  debugs(20, 9, "slice " << sliceId << " freed " << pageId);
821  assert(pageId);
822  Ipc::Mem::PageId slotId;
823  slotId.pool = SpacePoolId;
824  slotId.number = sliceId + 1;
825  if (!waitingFor) {
826  // must zero pageId before we give slice (and pageId extras!) to others
827  Ipc::Mem::PutPage(pageId);
828  freeSlots->push(slotId);
829  } else {
830  *waitingFor.slot = slotId;
831  *waitingFor.page = pageId;
832  waitingFor.slot = NULL;
833  waitingFor.page = NULL;
834  pageId = Ipc::Mem::PageId();
835  }
836 }
837 
838 void
840 {
841  assert(e.mem_obj);
842 
843  debugs(20, 7, "entry " << e);
844 
845  switch (e.mem_obj->memCache.io) {
847  if (!shouldCache(e) || !startCaching(e)) {
849  e.memOutDecision(false);
850  return;
851  }
852  break;
853 
854  case MemObject::ioDone:
856  return; // we should not write in all of the above cases
857 
859  break; // already decided to write and still writing
860  }
861 
862  try {
863  copyToShm(e);
864  if (e.store_status == STORE_OK) // done receiving new content
865  completeWriting(e);
866  else
868  return;
869  } catch (const std::exception &x) { // TODO: should we catch ... as well?
870  debugs(20, 2, "mem-caching error writing entry " << e << ": " << x.what());
871  // fall through to the error handling code
872  }
873 
874  disconnect(e);
875 }
876 
877 void
879 {
880  assert(e.mem_obj);
881  const int32_t index = e.mem_obj->memCache.index;
882  assert(index >= 0);
883  assert(map);
884 
885  debugs(20, 5, "mem-cached all " << e.mem_obj->memCache.offset << " bytes of " << e);
886 
887  e.mem_obj->memCache.index = -1;
889  map->closeForWriting(index, false);
890 
891  CollapsedForwarding::Broadcast(e); // before we close our transient entry!
893 }
894 
895 void
897 {
898  debugs(47, 5, e);
899  if (e.hasMemStore()) {
902  if (!e.locked()) {
903  disconnect(e);
904  e.destroyMemObject();
905  }
906  } else if (const auto key = e.publicKey()) {
907  // the entry may have been loaded and then disconnected from the cache
908  evictIfFound(key);
909  if (!e.locked())
910  e.destroyMemObject();
911  }
912 }
913 
914 void
916 {
917  if (map)
918  map->freeEntryByKey(key);
919 }
920 
921 void
923 {
924  assert(e.mem_obj);
925  MemObject &mem_obj = *e.mem_obj;
926  if (e.hasMemStore()) {
927  if (mem_obj.memCache.io == MemObject::ioWriting) {
928  map->abortWriting(mem_obj.memCache.index);
929  mem_obj.memCache.index = -1;
930  mem_obj.memCache.io = MemObject::ioDone;
931  Store::Root().stopSharing(e); // broadcasts after the change
932  } else {
934  map->closeForReading(mem_obj.memCache.index);
935  mem_obj.memCache.index = -1;
936  mem_obj.memCache.io = MemObject::ioDone;
937  }
938  }
939 }
940 
942 int64_t
944 {
946  return 0; // no memory cache configured
947 
948  const int64_t minEntrySize = Ipc::Mem::PageSize();
949  const int64_t entryLimit = Config.memMaxSize / minEntrySize;
950  return entryLimit;
951 }
952 
957 {
958 public:
959  /* RegisteredRunner API */
961  virtual void finalizeConfig();
962  virtual void claimMemoryNeeds();
963  virtual void useConfig();
964  virtual ~MemStoreRr();
965 
966 protected:
967  /* Ipc::Mem::RegisteredRunner API */
968  virtual void create();
969 
970 private:
974 };
975 
977 
978 void
980 {
982 }
983 
984 void
986 {
987  // decide whether to use a shared memory cache if the user did not specify
988  if (!Config.memShared.configured()) {
990  Config.memMaxSize > 0);
991  } else if (Config.memShared && !Ipc::Mem::Segment::Enabled()) {
992  fatal("memory_cache_shared is on, but no support for shared memory detected");
993  } else if (Config.memShared && !UsingSmp()) {
994  debugs(20, DBG_IMPORTANT, "WARNING: memory_cache_shared is on, but only"
995  " a single worker is running");
996  }
997 }
998 
999 void
1001 {
1004 }
1005 
1006 void
1008 {
1009  if (!Config.memShared)
1010  return;
1011 
1012  const int64_t entryLimit = MemStore::EntryLimit();
1013  if (entryLimit <= 0) {
1014  if (Config.memMaxSize > 0) {
1015  debugs(20, DBG_IMPORTANT, "WARNING: mem-cache size is too small ("
1016  << (Config.memMaxSize / 1024.0) << " KB), should be >= " <<
1017  (Ipc::Mem::PageSize() / 1024.0) << " KB");
1018  }
1019  return; // no memory cache configured or a misconfiguration
1020  }
1021 
1022  Must(!spaceOwner);
1024  entryLimit, 0);
1025  Must(!mapOwner);
1026  mapOwner = MemStoreMap::Init(MapLabel, entryLimit);
1027  Must(!extrasOwner);
1029 }
1030 
1032 {
1033  delete extrasOwner;
1034  delete mapOwner;
1035  delete spaceOwner;
1036 }
1037 
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: MemStore.cc:267
sfileno fileNo
StoreMap::fileNos[name], for convenience/speed.
Definition: StoreMap.h:163
virtual void claimMemoryNeeds()
Definition: MemStore.cc:979
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: MemStore.cc:211
std::atomic< uint64_t > swap_file_sz
Definition: StoreMap.h:93
bool freeEntry(const sfileno)
Definition: StoreMap.cc:259
bool complete() const
Definition: StoreMap.h:74
#define assert(EX)
Definition: assert.h:17
struct Ipc::StoreMapAnchor::Basics basics
size_t maxInMemObjSize
Definition: SquidConfig.h:264
virtual uint64_t maxSize() const override
Definition: MemStore.cc:273
void closeForWriting(const sfileno fileno, bool lockForReading=false)
successfully finish creating or updating the entry at fileno pos
Definition: StoreMap.cc:158
std::atomic< StoreMapSliceId > next
ID of the next entry slice.
Definition: StoreMap.h:46
virtual void append(const char *c, int sz)
Definition: MemBuf.cc:225
const char * buf
content being appended now
Definition: MemStore.cc:70
Aggregates information required for updating entry metadata and headers.
Definition: StoreMap.h:150
SlotAndPage waitingFor
a cache for a single "hot" free slot and page
Definition: MemStore.h:113
ParseState pstate
the current parsing state
Definition: Message.h:94
void copyToShm(StoreEntry &e)
copies all local data to shared memory
Definition: MemStore.cc:662
void push(PageId &page)
makes value available as a free page number to future pop() callers
Definition: PageStack.cc:76
int entryLimit() const
maximum entryCount() possible
Definition: StoreMap.cc:648
int hdr_sz
Definition: Message.h:81
double size
bytes currently in use
Definition: StoreStats.h:20
Definition: SBuf.h:87
std::atomic< Size > size
slice contents size
Definition: StoreMap.h:45
Ipc::Mem::Pointer< Ipc::Mem::PageStack > freeSlots
unused map slot IDs
Definition: MemStore.h:95
char * PagePointer(const PageId &page)
converts page handler into a temporary writeable shared memory pointer
Definition: Pages.cc:48
unsigned char cache_key
Store key.
Definition: forward.h:29
static constexpr Io ioWriting
Definition: MemObject.h:131
#define shm_old(Class)
Definition: Pointer.h:180
virtual ~MemStoreRr()
Definition: MemStore.cc:1031
void completeWriting(StoreEntry &e)
all data has been received; there will be no more write() calls
Definition: MemStore.cc:878
void freeEntryByKey(const cache_key *const key)
Definition: StoreMap.cc:277
int64_t endOffset() const
Definition: MemObject.cc:229
#define PRId64
Definition: types.h:110
static const uint32_t SpacePoolId
Definition: MemStore.cc:36
Ipc::Mem::PageId * slot
local slot variable, waiting to be filled
Definition: MemStore.h:110
ShmWriter(MemStore &aStore, StoreEntry *anEntry, const sfileno aFileNo, Ipc::StoreMapSliceId aFirstSlice=-1)
Definition: MemStore.cc:77
void stopSharing(StoreEntry &)
stop any current (and prevent any future) SMP sharing of the given entry
Definition: Controller.cc:577
Ipc::StoreMap MemStoreMap
Definition: MemStore.h:23
MemStoreMap * map
index of mem-cached entries
Definition: MemStore.h:96
virtual void init() override
Definition: MemStore.cc:180
YesNoNone memShared
whether the memory cache is shared among workers
Definition: SquidConfig.h:79
void abortUpdating(Update &update)
undoes partial update, unlocks, and cleans up
Definition: StoreMap.cc:223
void updateHeadersOrThrow(Ipc::StoreMapUpdate &update)
Definition: MemStore.cc:362
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:2008
Io io
current I/O state
Definition: MemObject.h:154
MemStore()
Definition: MemStore.cc:170
bool shouldCache(StoreEntry &e) const
whether we should cache the entry
Definition: MemStore.cc:585
class Ping::pingStats_ stats
bool copyFromShm(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
copies the entire entry from shared to local memory
Definition: MemStore.cc:470
virtual void finalizeConfig()
Definition: MemStore.cc:985
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: MemStore.cc:286
void NotePageNeed(const int purpose, const int count)
claim the need for a number of pages for a given purpose
Definition: Pages.cc:72
StoreMapCleaner * cleaner
notified before a readable entry is freed
Definition: StoreMap.h:308
approximate stats of a set of ReadWriteLocks
Definition: ReadWriteLock.h:56
struct SquidConfig::@110 Store
uint32_t Size
Definition: StoreMap.h:31
static void Broadcast(const StoreEntry &e, const bool includingThisWorker=false)
notify other workers about changes in entry state (e.g., new data)
bool GetPage(const PageId::Purpose purpose, PageId &page)
sets page ID and returns true unless no free pages are found
Definition: Pages.cc:34
bool isEmpty() const
Definition: SBuf.h:421
virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override
adjust slice-linked state before a locked Readable slice is erased
Definition: MemStore.cc:817
static Owner * Init(const SBuf &path, const int slotLimit)
initialize shared memory
Definition: StoreMap.cc:38
static const SBuf MapLabel("cache_mem_map")
shared memory segment path to use for MemStore maps
bool openForUpdating(Update &update, sfileno fileNoHint)
finds and locks the Update entry for an exclusive metadata update
Definition: StoreMap.cc:435
Controller & Root()
safely access controller singleton
Definition: Controller.cc:845
uint32_t pool
page pool ID within Squid
Definition: Page.h:33
Ipc::Mem::PageId * page
local page variable, waiting to be filled
Definition: MemStore.h:111
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: MemStore.cc:292
RunnerRegistrationEntry(MemStoreRr)
double count
number of cached objects
Definition: StoreStats.h:21
void memOutDecision(const bool willCacheInRam)
Definition: store.cc:1867
void destroyMemObject()
Definition: store.cc:372
A const & max(A const &lhs, A const &rhs)
MemCache memCache
current [shared] memory caching state for the entry
Definition: MemObject.h:156
static constexpr Io ioUndecided
Definition: MemObject.h:129
int32_t index
entry position inside the memory cache
Definition: MemObject.h:151
Ipc::StoreMap::Slice & nextAppendableSlice(const sfileno entryIndex, sfileno &sliceOffset)
Definition: MemStore.cc:735
virtual void evictIfFound(const cache_key *) override
Definition: MemStore.cc:915
bool updateAnchoredWith(StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &)
updates Transients entry after its anchor has been located
Definition: MemStore.cc:436
void anchorEntry(StoreEntry &e, const sfileno index, const Ipc::StoreMapAnchor &anchor)
anchors StoreEntry to an already locked map entry
Definition: MemStore.cc:445
void init(mb_size_t szInit, mb_size_t szMax)
Definition: MemBuf.cc:105
virtual uint64_t currentSize() const override
current size
Definition: MemStore.cc:279
static bool Enabled()
Whether shared memory support is available.
Definition: Segment.cc:321
double capacity
the size limit
Definition: StoreStats.h:22
bool copyFromShmSlice(StoreEntry &e, const StoreIOBuffer &buf, bool eof)
imports one shared memory slice into local memory
Definition: MemStore.cc:547
double doublePercent(const double, const double)
Definition: SquidMath.cc:25
Mem mem
all cache_dirs stats
Definition: StoreStats.h:49
int locked() const
Definition: store.cc:1265
uint64_t swap_file_sz
Definition: Store.h:200
int bufSize
buf size
Definition: MemStore.cc:71
uint32_t number
page number within the segment
Definition: Page.h:35
bool startCaching(StoreEntry &e)
locks map anchor and preps to store the entry in shared memory
Definition: MemStore.cc:639
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:405
int64_t offset
Definition: StoreIOBuffer.h:55
State of an entry with regards to the [shared] memory caching.
Definition: MemObject.h:146
bool write(StoreIOBuffer const &)
Definition: stmem.cc:342
int64_t object_sz
Definition: MemObject.h:172
size_t PagesAvailable()
approximate total number of shared memory pages we can allocate now
Definition: Pages.h:47
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:121
void startAppending(const sfileno fileno)
restrict opened for writing entry to appending operations; allow reads
Definition: StoreMap.cc:149
virtual ~MemStore()
Definition: MemStore.cc:174
#define DBG_IMPORTANT
Definition: Debug.h:46
bool pop(PageId &page)
sets value and returns true unless no free page numbers are found
Definition: PageStack.cc:40
virtual void evictCached(StoreEntry &) override
Definition: MemStore.cc:896
void write(StoreEntry &e)
copy non-shared entry data of the being-cached entry to our cache
Definition: MemStore.cc:839
bool configured() const
Definition: YesNoNone.h:67
virtual HttpReply const * getReply() const
Definition: store.cc:1686
virtual bool anchorToCache(StoreEntry &e, bool &inSync) override
Definition: MemStore.cc:405
#define EBIT_CLR(flag, bit)
Definition: defines.h:106
mem_status_t mem_status
Definition: Store.h:210
virtual void vappendf(const char *fmt, va_list ap) override
Definition: MemStore.cc:108
Slice & writeableSlice(const AnchorId anchorId, const SliceId sliceId)
writeable slice within an entry chain created by openForWriting()
Definition: StoreMap.cc:175
virtual bool dereference(StoreEntry &e) override
Definition: MemStore.cc:303
bool hasMemStore() const
whether there is a corresponding locked shared memory table entry
Definition: Store.h:189
virtual void stat(StoreEntry &e) const override
Definition: MemStore.cc:224
int32_t StoreMapSliceId
Definition: StoreMap.h:24
SliceId sliceContaining(const sfileno fileno, const uint64_t nth) const
Definition: StoreMap.cc:360
void updateStats(ReadWriteLockStats &stats) const
adds approximate current stats to the supplied ones
Definition: StoreMap.cc:666
void fatal(const char *message)
Definition: fatal.cc:39
MemStore & store
Definition: MemStore.cc:66
Anchor & writeableEntry(const AnchorId anchorId)
writeable anchor for the entry created by openForWriting()
Definition: StoreMap.cc:191
const sfileno fileNo
Definition: MemStore.cc:67
void abortWriting(const sfileno fileno)
stop writing the entry, freeing its slot for others to use if possible
Definition: StoreMap.cc:205
uint16_t flags
Definition: Store.h:202
void copyToShm()
copies the entire buffer to shared memory
Definition: MemStore.cc:124
ssize_t copy(StoreIOBuffer const &) const
Definition: stmem.cc:226
StoreMapAnchor * anchor
StoreMap::anchors[fileNo], for convenience/speed.
Definition: StoreMap.h:162
void configure(bool beSet)
enables or disables the option; updating to 'configured' state
Definition: YesNoNone.h:53
signed_int32_t sfileno
Definition: forward.h:22
MemObject * mem_obj
Definition: Store.h:191
void disconnect(StoreEntry &e)
called when the entry is about to forget its association with mem cache
Definition: MemStore.cc:922
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:658
virtual StoreEntry * get(const cache_key *) override
Definition: MemStore.cc:310
Ipc::Mem::Owner< Ipc::Mem::PageStack > * spaceOwner
free slices Owner
Definition: MemStore.cc:971
void const char * buf
Definition: stub_helper.cc:16
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:145
#define shm_new(Class)
Definition: Pointer.h:179
bool shared
whether memory cache is shared among workers
Definition: StoreStats.h:42
bool set() const
true if and only if both critical components have been initialized
Definition: Page.h:27
static int64_t EntryLimit()
calculates maximum number of entries we need to store and map
Definition: MemStore.cc:943
Definition: enums.h:46
int sliceLimit() const
maximum number of slices possible
Definition: StoreMap.cc:660
SBuf vary_headers
Definition: MemObject.h:179
size_t PageSize()
returns page size in bytes; all pages are assumed to be the same size
Definition: Pages.cc:28
char * buf
Definition: MemBuf.h:134
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: MemStore.cc:262
#define EBIT_SET(flag, bit)
Definition: defines.h:105
void transientsCompleteWriting(StoreEntry &)
marks the entry completed for collapsed requests
Definition: Controller.cc:587
store_status_t store_status
Definition: Store.h:214
const Anchor * openForReading(const cache_key *const key, sfileno &fileno)
opens entry (identified by key) for reading, increments read level
Definition: StoreMap.cc:379
virtual bool updateAnchored(StoreEntry &) override
Definition: MemStore.cc:422
const Anchor & readableEntry(const AnchorId anchorId) const
readable anchor for the entry created by openForReading()
Definition: StoreMap.cc:198
Edition stale
old anchor and chain being updated
Definition: StoreMap.h:177
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:704
bool memoryCachable()
checkCachable() and can be cached in memory
Definition: store.cc:1355
StoreEntry * entry
the entry being updated
Definition: MemStore.cc:50
Store::DiskConfig cacheSwap
Definition: SquidConfig.h:418
Ipc::StoreMapSliceId lastSlice
the slot keeping the last byte of the appended content (at least)
Definition: MemStore.cc:57
Ipc::Mem::Owner< MemStoreMapExtras > * extrasOwner
PageIds Owner.
Definition: MemStore.cc:973
Edition fresh
new anchor and updated chain prefix
Definition: StoreMap.h:178
virtual void useConfig()
Definition: Segment.cc:376
int bufWritten
buf bytes appended so far
Definition: MemStore.cc:72
aggregates anchor and slice owners for Init() caller convenience
Definition: StoreMap.h:201
void exportInto(StoreEntry &) const
load StoreEntry basics that were previously stored with set()
Definition: StoreMap.cc:795
const cache_key * publicKey() const
Definition: Store.h:98
Shared memory page identifier, address, or handler.
Definition: Page.h:21
sfileno reserveSapForWriting(Ipc::Mem::PageId &page)
finds a slot and a free page to fill or throws
Definition: MemStore.cc:782
size_t PageLevel()
approximate total number of shared memory pages used now
Definition: Pages.cc:80
Definition: MemBuf.h:23
void packHeadersInto(Packable *p) const
Definition: HttpReply.cc:85
size_t memMaxSize
Definition: SquidConfig.h:81
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:55
int httpMsgParseStep(const char *buf, int len, int atEnd)
Definition: Message.cc:169
static const char * SpaceLabel
shared memory segment path to use for the free slices index
Definition: MemStore.cc:28
void PutPage(PageId &page)
makes identified page available as a free page to future GetPage() callers
Definition: Pages.cc:41
Ipc::Mem::Pointer< Extras > extras
IDs of pages with slice data.
Definition: MemStore.h:99
virtual void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: MemStore.cc:298
void set(const StoreEntry &anEntry, const cache_key *aKey=nullptr)
store StoreEntry key and basics for an inode slot
Definition: StoreMap.cc:775
bool purgeOne()
either finds and frees an entry with at least 1 slice or returns false
Definition: StoreMap.cc:617
const Slice & readableSlice(const AnchorId anchorId, const SliceId sliceId) const
readable slice within an entry chain opened by openForReading()
Definition: StoreMap.cc:183
StoreMapSliceId splicingPoint
the last slice in the chain still containing metadata/headers
Definition: StoreMap.h:167
virtual void append(const char *aBuf, int aSize) override
Appends a c-string to existing packed data.
Definition: MemStore.cc:92
static const char * ExtrasLabel
shared memory segment path to use for IDs of shared pages with slice data
Definition: MemStore.cc:30
SBuf & vappendf(const char *fmt, va_list vargs)
Definition: SBuf.cc:258
Anchor * openForWriting(const cache_key *const key, sfileno &fileno)
Definition: StoreMap.cc:98
mem_hdr data_hdr
Definition: MemObject.h:102
static constexpr Io ioDone
Definition: MemObject.h:132
sfileno lastWritingSlice
the last allocate slice for writing a store entry (during copyToShm)
Definition: MemStore.h:102
static constexpr Io ioReading
Definition: MemObject.h:130
const char * rawContent() const
Definition: SBuf.cc:532
bool isContiguous() const
Definition: MemObject.cc:403
Ipc::StoreMapSliceId firstSlice
Definition: MemStore.cc:54
virtual void create()
called when the runner should create a new memory segment
Definition: MemStore.cc:1007
void closeForReading(const sfileno fileno)
closes open entry after reading, decrements read level
Definition: StoreMap.cc:426
std::atomic< StoreMapSliceId > start
where the chain of StoreEntry slices begins [app]
Definition: StoreMap.h:99
FREE destroyStoreEntry
uint64_t totalWritten
cumulative number of bytes appended so far
Definition: MemStore.cc:59
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:898
int entryCount() const
number of writeable and readable entries
Definition: StoreMap.cc:654
virtual void updateHeaders(StoreEntry *e) override
make stored metadata and HTTP headers the same as in the given entry
Definition: MemStore.cc:342
MemStoreMap::Owner * mapOwner
primary map Owner
Definition: MemStore.cc:972
#define EBIT_TEST(flag, bit)
Definition: defines.h:107
size_t PageLimit()
the total number of shared memory pages that can be in use at any time
Definition: Pages.cc:55
class SquidConfig Config
Definition: SquidConfig.cc:12
#define NULL
Definition: types.h:166
void copyToShmSlice(Ipc::StoreMap::Slice &slice)
copies at most one slice worth of buffer to shared memory
Definition: MemStore.cc:142
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Controller.cc:181
Ipc::Mem::PageId pageForSlice(Ipc::StoreMapSliceId sliceId)
safely returns a previously allocated memory page for the given entry slice
Definition: MemStore.cc:771
int64_t expectedReplySize() const
Definition: MemObject.cc:253
A const & min(A const &lhs, A const &rhs)
void closeForUpdating(Update &update)
makes updated info available to others, unlocks, and cleans up
Definition: StoreMap.cc:523
void dump(StoreEntry &e) const
int64_t offset
bytes written/read to/from the memory cache so far
Definition: MemObject.h:152
virtual void useConfig()
Definition: MemStore.cc:1000
StoreEntry * entry
the store entry being updated
Definition: StoreMap.h:176
void setMemStatus(mem_status_t)
Definition: store.cc:1574
void terminate()
Definition: MemBuf.cc:259
void createMemObject()
Definition: store.cc:1625

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors