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);
571 debugs(72, 2,
"peerDigestSwapInMask: Done! Got " <<
572 fetch->
mask_offset <<
", expected " << pd->cd->mask_size);
585 static const SBuf hostUnknown(
"<unknown>");
586 SBuf host = hostUnknown;
588 const auto pd = fetch->
pd.
get();
590 const char *reason =
nullptr;
591 const char *no_bug =
nullptr;
600 debugs(72, 6, step_name <<
": peer " << host <<
", offset: " <<
607 reason =
"swap failure";
608 else if (!fetch->
entry)
609 reason =
"swap aborted?!";
611 reason =
"swap aborted";
617 reason =
"null digest?!";
619 reason =
"premature end of digest?!";
621 reason =
"useless digest";
623 reason = no_bug =
"success";
628 const int level = strstr(reason,
"?!") ? 1 : 3;
629 debugs(72, level,
"" << step_name <<
": peer " << host <<
", exiting after '" << reason <<
"'");
633 return reason !=
nullptr;
646 if (
const auto pd = fetch->
pd.
get())
647 pd->noteFetchFinished(*fetch, reason, err);
655 const auto pd =
this;
656 const auto fetch = &finishedFetch;
658 pd->flags.requested =
false;
659 pd->req_result = outcomeDescription;
663 pd->stats.sent.kbytes += fetch->sent.bytes;
664 pd->stats.recv.kbytes += fetch->recv.bytes;
665 pd->stats.sent.msgs += fetch->sent.msg;
666 pd->stats.recv.msgs += fetch->recv.msg;
676 pd->flags.usable =
false;
678 pd->flags.usable =
true;
679 pd->times.retry_delay = 0;
684 if (fetch->entry->store_status ==
STORE_OK)
685 debugs(72, 2,
"reused old digest from " <<
host);
687 debugs(72, 2,
"received valid digest from " <<
host);
713 " bytes in " << (
int) fetch->
resp_time <<
" secs");
715 debugs(72, 3,
"peerDigestFetchFinish: expires: " <<
716 (
long int) fetch->
expires <<
" (" << std::showpos <<
733 const auto host = pd->
host;
735 memcpy(&cblock, buf,
sizeof(cblock));
743 debugs(72, 2,
"got digest cblock from " << host <<
"; ver: " <<
747 debugs(72, 2,
"\t size: " <<
749 cblock.
count <<
", e-util: " <<
779 "(mask size mismatch: " << cblock.
mask_size <<
" ? " <<
787 debugs(72,
DBG_CRITICAL,
"ERROR: " << host <<
" digest: unsupported #hash functions: " <<
805 debugs(72, 2,
"creating " << host <<
" digest; size: " << cblock.
mask_size <<
" (" <<
806 std::showpos << (
int) (cblock.
mask_size - freed_size) <<
") bytes");
826 if (bit_util > 65.0) {
828 " peer digest has too many bits on (" << bit_util <<
"%).");
844#define f2s(flag) (pd->flags.flag ? "yes" : "no")
845#define appendTime(tm) storeAppendPrintf(e, "%s\t %10ld\t %+d\t %+d\n", \
846 ""#tm, (long int)pd->times.tm, \
847 saneDiff(pd->times.tm - squid_curtime), \
848 saneDiff(pd->times.tm - pd->times.initialized))
852 auto host = pd->
host;
866 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)