53#define StoreDigestCBlockSize sizeof(StoreDigestCBlock)
104 debugs(72, 3,
"deleting old entry");
170 debugs(72, 3,
"peerDigestSetCheck: will check peer " << pd->
host <<
" in " << delay <<
" secs");
190 ", last received: " << (
long int) pd->
times.
received <<
" (" <<
200 debugs(72, 2,
"peerDigestCheck: " << pd->
host <<
201 ", avoiding close peer requests (" <<
210 debugs(72, 2,
"peerDigestCheck: " << pd->
host <<
211 ", avoiding close requests (" <<
245 const auto mx = MasterXaction::MakePortless<XactionInitiator::initCacheDigest>();
258 p->login[0] !=
'*' &&
259 strcmp(p->login,
"PASS") != 0 &&
260 strcmp(p->login,
"PASSTHRU") != 0 &&
261 strncmp(p->login,
"NEGOTIATE",9) != 0 &&
262 strcmp(p->login,
"PROXYPASS") != 0) {
280 debugs(72, 5,
"found old " << *old_e);
282 old_e->
lock(
"peerDigestRequest");
289 debugs(72, 5,
"created " << *e);
368 prevstate = fetch->
state;
370 switch (fetch->
state) {
388 fatal(
"Bad digest transfer mode!\n");
399 newsize = fetch->
bufofs - retsize;
401 memmove(fetch->
buf, fetch->
buf + retsize, newsize);
435 const auto pd = fetch->
pd.
get();
448 debugs(72, 3,
"peerDigestFetchReply: " << pd->host <<
" status: " << status <<
449 ", expires: " << (
long int) reply.expires <<
" (" << std::showpos <<
481 if (!fetch->
pd->
cd) {
493 debugs(72, 3,
"peerDigestFetchReply: got new digest, releasing old one");
522 const auto pd = fetch->
pd.
get();
553 const auto pd = fetch->
pd.
get();
555 assert(pd->cd && pd->cd->mask);
563 if (
static_cast<size_t>(
size) > pd->cd->mask_size - fetch->
mask_offset) {
577 debugs(72, 2,
"peerDigestSwapInMask: Done! Got " <<
578 fetch->
mask_offset <<
", expected " << pd->cd->mask_size);
591 static const SBuf hostUnknown(
"<unknown>");
592 SBuf host = hostUnknown;
594 const auto pd = fetch->
pd.
get();
596 const char *reason =
nullptr;
597 const char *no_bug =
nullptr;
606 debugs(72, 6, step_name <<
": peer " << host <<
", offset: " <<
613 reason =
"swap failure";
614 else if (!fetch->
entry)
615 reason =
"swap aborted?!";
617 reason =
"swap aborted";
623 reason =
"null digest?!";
625 reason =
"premature end of digest?!";
627 reason =
"useless digest";
629 reason = no_bug =
"success";
634 const int level = strstr(reason,
"?!") ? 1 : 3;
635 debugs(72, level,
"" << step_name <<
": peer " << host <<
", exiting after '" << reason <<
"'");
639 return reason !=
nullptr;
652 if (
const auto pd = fetch->
pd.
get())
653 pd->noteFetchFinished(*fetch, reason, err);
661 const auto pd =
this;
662 const auto fetch = &finishedFetch;
664 pd->flags.requested =
false;
665 pd->req_result = outcomeDescription;
669 pd->stats.sent.kbytes += fetch->sent.bytes;
670 pd->stats.recv.kbytes += fetch->recv.bytes;
671 pd->stats.sent.msgs += fetch->sent.msg;
672 pd->stats.recv.msgs += fetch->recv.msg;
682 pd->flags.usable =
false;
684 pd->flags.usable =
true;
685 pd->times.retry_delay = 0;
690 if (fetch->entry->store_status ==
STORE_OK)
691 debugs(72, 2,
"reused old digest from " <<
host);
693 debugs(72, 2,
"received valid digest from " <<
host);
719 " bytes in " << (
int) fetch->
resp_time <<
" secs");
721 debugs(72, 3,
"peerDigestFetchFinish: expires: " <<
722 (
long int) fetch->
expires <<
" (" << std::showpos <<
739 const auto host = pd->
host;
741 memcpy(&cblock, buf,
sizeof(cblock));
749 debugs(72, 2,
"got digest cblock from " << host <<
"; ver: " <<
753 debugs(72, 2,
"\t size: " <<
755 cblock.
count <<
", e-util: " <<
785 "(mask size mismatch: " << cblock.
mask_size <<
" ? " <<
793 debugs(72,
DBG_CRITICAL,
"ERROR: " << host <<
" digest: unsupported #hash functions: " <<
811 debugs(72, 2,
"creating " << host <<
" digest; size: " << cblock.
mask_size <<
" (" <<
812 std::showpos << (
int) (cblock.
mask_size - freed_size) <<
") bytes");
832 if (bit_util > 65.0) {
834 " peer digest has too many bits on (" << bit_util <<
"%).");
850#define f2s(flag) (pd->flags.flag ? "yes" : "no")
851#define appendTime(tm) storeAppendPrintf(e, "%s\t %10ld\t %+d\t %+d\n", \
852 ""#tm, (long int)pd->times.tm, \
853 saneDiff(pd->times.tm - squid_curtime), \
854 saneDiff(pd->times.tm - pd->times.initialized))
858 auto host = pd->
host;
872 f2s(needed),
f2s(usable),
f2s(requested));
#define Assure(condition)
void cacheDigestGuessStatsReport(const CacheDigestGuessStats *stats, StoreEntry *sentry, const SBuf &label)
void cacheDigestReport(CacheDigest *cd, const SBuf &label, StoreEntry *e)
RawPointerT< Pointer > RawPointer(const char *label, const Pointer &ptr)
convenience wrapper for creating RawPointerT<> objects
#define SQUIDSBUFPRINT(s)
void(void *, StoreIOBuffer) STCB
int cbdataReferenceValid(const void *p)
#define CBDATA_CLASS_INIT(type)
void userInfo(const SBuf &s)
double usedMaskPercent() const
percentage of mask bits which are used
static uint32_t CalcMaskSize(uint64_t cap, uint8_t bpe)
Cbc * valid() const
was set and is valid
Cbc * get() const
a temporary valid raw Cbc pointer or NULL
CbcPointer< PeerDigest > pd
struct DigestFetchState::@66 recv
struct DigestFetchState::@66 sent
DigestFetchState(PeerDigest *, HttpRequest *)
digest_read_state_t state
static void fwdStart(const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *)
Same as Start() but no master xaction info (AccessLogEntry) available.
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
AnyP::Uri url
the request URI
Http::StatusCode status() const
retrieve the status code for this status line
HttpRequestPointer request
const HttpReply & freshestReply() const
CacheDigestGuessStats guess
struct PeerDigest::@68 times
CbcPointer< CachePeer > peer
pointer back to peer structure, argh
void noteFetchFinished(const DigestFetchState &, const char *outcomeDescription, bool sawError)
struct PeerDigest::@69 stats
struct PeerDigest::@67 flags
struct PeerDigest::@69::@70 sent
struct PeerDigest::@69::@70 recv
const SBuf host
copy of peer->host
SupportOrVeto cachable
whether the response may be stored in the cache
struct StatCounters::@110 cd
unsigned char bits_per_entry
unsigned char hash_func_count
void ensureMemObject(const char *storeId, const char *logUri, const HttpRequestMethod &aMethod)
initialize mem_obj (if needed) and set URIs/method (if missing)
int unlock(const char *context)
void lastModified(const time_t when)
void lock(const char *context)
void releaseRequest(const bool shareable=false)
struct StoreIOBuffer::@123 flags
#define debugs(SECTION, LEVEL, CONTENT)
#define EBIT_TEST(flag, bit)
int eventFind(EVH *func, void *arg)
void eventDelete(EVH *func, void *arg)
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
void fatal(const char *message)
int CacheDigestHashFuncCount
const char * StoreDigestMimeStr
const char * StoreDigestFileName
void HTTPMSGUNLOCK(M *&a)
void HTTPMSGLOCK(Http::Message *a)
char * internalRemoteUri(bool encrypt, const char *host, unsigned short port, const char *dir, const SBuf &name)
Controller & Root()
safely access controller singleton
#define StoreDigestCBlockSize
static void finishAndDeleteFetch(DigestFetchState *, const char *reason, bool sawError)
int peerDigestSwapInCBlock(void *, char *, ssize_t)
static time_t peerDigestIncDelay(const PeerDigest *pd)
static EVH peerDigestCheck
static void peerDigestSetCheck(PeerDigest *pd, time_t delay)
static STCB peerDigestHandleReply
static void peerDigestRequest(PeerDigest *pd)
void peerDigestStatsReport(const PeerDigest *pd, StoreEntry *e)
static const time_t GlobDigestReqMinGap
static void peerDigestFetchSetStats(DigestFetchState *fetch)
static int peerDigestFetchedEnough(DigestFetchState *fetch, char *buf, ssize_t size, const char *step_name)
static int peerDigestSetCBlock(PeerDigest *pd, const char *buf)
static time_t peerDigestNewDelay(const StoreEntry *e)
static int peerDigestFetchReply(void *, char *, ssize_t)
handle HTTP response headers in the initial storeClientCopy() response
void peerDigestNeeded(PeerDigest *pd)
Version const CacheDigestVer
static int saneDiff(time_t diff)
static time_t pd_last_req_time
static int peerDigestUseful(const PeerDigest *pd)
int peerDigestSwapInMask(void *, char *, ssize_t)
static const time_t PeerDigestReqMinGap
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
StoreEntry * storeGetPublicByRequest(HttpRequest *req, const KeyScope keyScope)
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
int storeUnregister(store_client *sc, StoreEntry *e, void *data)
void storeClientCopy(store_client *sc, StoreEntry *e, StoreIOBuffer copyInto, STCB *callback, void *data)
store_client * storeClientListAdd(StoreEntry *e, void *data)
int xpercentInt(double part, double whole)