neighbors.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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 15 Neighbor Routines */
10
11#include "squid.h"
12#include "acl/FilledChecklist.h"
13#include "anyp/PortCfg.h"
14#include "base/EnumIterator.h"
15#include "base/IoManip.h"
16#include "CacheDigest.h"
17#include "CachePeer.h"
18#include "comm/Connection.h"
19#include "comm/ConnOpener.h"
20#include "debug/Messages.h"
21#include "event.h"
22#include "FwdState.h"
23#include "globals.h"
24#include "htcp.h"
25#include "HttpRequest.h"
26#include "icmp/net_db.h"
27#include "ICP.h"
28#include "int.h"
29#include "ip/Address.h"
30#include "ip/tools.h"
31#include "ipcache.h"
32#include "MemObject.h"
33#include "mgr/Registration.h"
34#include "multicast.h"
35#include "neighbors.h"
37#include "pconn.h"
38#include "PeerDigest.h"
39#include "PeerPoolMgr.h"
40#include "PeerSelectState.h"
41#include "RequestFlags.h"
42#include "SquidConfig.h"
43#include "SquidMath.h"
44#include "stat.h"
45#include "Store.h"
46#include "store_key_md5.h"
47#include "tools.h"
48
49/* count mcast group peers every 15 minutes */
50#define MCAST_COUNT_RATE 900
51
53static int peerWouldBePinged(const CachePeer *, PeerSelector *);
54static void neighborRemove(CachePeer *);
55static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *);
56#if USE_HTCP
57static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *);
58#endif
59static void neighborCountIgnored(CachePeer *);
60static void peerRefreshDNS(void *);
62static void peerProbeConnect(CachePeer *, const bool reprobeIfBusy = false);
64static void peerCountMcastPeersDone(void *data);
65static void peerCountMcastPeersStart(void *data);
66static void peerCountMcastPeersSchedule(CachePeer * p, time_t when);
70
71static void neighborIgnoreNonPeer(const Ip::Address &, icp_opcode);
74static void dump_peers(StoreEntry * sentry, CachePeer * peers);
75
76static unsigned short echo_port;
77
78static int NLateReplies = 0;
79static CachePeer *first_ping = nullptr;
80
81const char *
83{
84 if (p->type == PEER_NONE)
85 return "Non-Peer";
86
87 if (p->type == PEER_SIBLING)
88 return "Sibling";
89
90 if (p->type == PEER_MULTICAST)
91 return "Multicast Group";
92
93 return "Parent";
94}
95
98{
99 int j;
100
101 CachePeer *p = nullptr;
102 debugs(15, 3, "whichPeer: from " << from);
103
104 for (p = Config.peers; p; p = p->next) {
105 for (j = 0; j < p->n_addresses; ++j) {
106 if (from == p->addresses[j] && from.port() == p->icp.port) {
107 return p;
108 }
109 }
110 }
111
112 return nullptr;
113}
114
115peer_t
116neighborType(const CachePeer * p, const AnyP::Uri &url)
117{
118
119 const NeighborTypeDomainList *d = nullptr;
120
121 for (d = p->typelist; d; d = d->next) {
122 if (0 == matchDomainName(url.host(), d->domain))
123 if (d->type != PEER_NONE)
124 return d->type;
125 }
126#if PEER_MULTICAST_SIBLINGS
127 if (p->type == PEER_MULTICAST)
128 if (p->options.mcast_siblings)
129 return PEER_SIBLING;
130#endif
131
132 return p->type;
133}
134
138bool
140{
141 assert(ps);
142 HttpRequest *request = ps->request;
143 assert(request != nullptr);
144
145 if (neighborType(p, request->url) == PEER_SIBLING) {
146#if PEER_MULTICAST_SIBLINGS
147 if (p->type == PEER_MULTICAST && p->options.mcast_siblings &&
148 (request->flags.noCache || request->flags.refresh || request->flags.loopDetected || request->flags.needValidation))
149 debugs(15, 2, "multicast-siblings optimization match for " << *p << ", " << request->url.authority());
150#endif
151 if (request->flags.noCache)
152 return false;
153
154 if (request->flags.refresh)
155 return false;
156
157 if (request->flags.loopDetected)
158 return false;
159
160 if (request->flags.needValidation)
161 return false;
162 }
163
164 // CONNECT requests are proxy requests. Not to be forwarded to origin servers.
165 // Unless the destination port matches, in which case we MAY perform a 'DIRECT' to this CachePeer.
166 if (p->options.originserver && request->method == Http::METHOD_CONNECT && request->url.port() != p->http_port)
167 return false;
168
169 if (p->access == nullptr)
170 return true;
171
172 ACLFilledChecklist checklist(p->access, request, nullptr);
173 checklist.al = ps->al;
174 if (ps->al && ps->al->reply) {
175 checklist.reply = ps->al->reply.getRaw();
176 HTTPMSGLOCK(checklist.reply);
177 }
178 checklist.syncAle(request, nullptr);
179 return checklist.fastCheck().allowed();
180}
181
182/* Return TRUE if it is okay to send an ICP request to this CachePeer. */
183static int
185{
186 assert(ps);
187 HttpRequest *request = ps->request;
188
189 if (p->icp.port == 0)
190 return 0;
191
192 if (p->options.no_query)
193 return 0;
194
196 return 0;
197
198 if (p->n_addresses == 0)
199 return 0;
200
202 return 0;
203
204 /* the case below seems strange, but can happen if the
205 * URL host is on the other side of a firewall */
206 if (p->type == PEER_SIBLING)
207 if (!request->flags.hierarchical)
208 return 0;
209
210 if (!peerAllowedToUse(p, ps))
211 return 0;
212
213 /* Ping dead peers every timeout interval */
215 return 1;
216
217 if (!neighborUp(p))
218 return 0;
219
220 return 1;
221}
222
223bool
225{
226 const int effectiveLimit = p->max_conn <= 0 ? Squid_MaxFD : p->max_conn;
227 const int remaining = effectiveLimit - p->stats.conn_open;
228 debugs(15, 7, remaining << '=' << effectiveLimit << '-' << p->stats.conn_open);
229 return remaining > 0;
230}
231
232bool
234{
235 // Standby connections can be used without opening new connections.
236 const int standbys = p->standby.pool ? p->standby.pool->count() : 0;
237
238 // XXX: Some idle pconns can be used without opening new connections.
239 // Complication: Idle pconns cannot be reused for some requests.
240 const int usableIdles = 0;
241
242 const int available = standbys + usableIdles;
243 debugs(15, 7, available << '=' << standbys << '+' << usableIdles);
244 return available > 0;
245}
246
247void
249{
250 --p->stats.conn_open;
252 p->standby.waitingForClose = false;
253 PeerPoolMgr::Checkpoint(p->standby.mgr, "conn closed");
254 }
255}
256
257/* Return TRUE if it is okay to send an HTTP request to this CachePeer. */
258int
260{
262 return 0;
263
264 if (!peerAllowedToUse(p, ps))
265 return 0;
266
267 if (!neighborUp(p))
268 return 0;
269
270 return 1;
271}
272
273int
275{
276 CachePeer *p = nullptr;
277 int count = 0;
278
279 for (p = Config.peers; p; p = p->next)
280 if (peerWouldBePinged(p, ps))
281 ++count;
282
283 debugs(15, 3, "neighborsCount: " << count);
284
285 return count;
286}
287
288CachePeer *
290{
291 assert(ps);
292 HttpRequest *request = ps->request;
293
294 CachePeer *p = nullptr;
295
296 for (p = Config.peers; p; p = p->next) {
297 if (!neighborUp(p))
298 continue;
299
300 if (neighborType(p, request->url) != PEER_PARENT)
301 continue;
302
303 if (!peerHTTPOkay(p, ps))
304 continue;
305
306 break;
307 }
308
309 debugs(15, 3, "returning " << RawPointer(p).orNil());
310 return p;
311}
312
313CachePeer *
315{
316 assert(ps);
317 HttpRequest *request = ps->request;
318
319 CachePeer *p;
320 CachePeer *q = nullptr;
321
322 for (p = Config.peers; p; p = p->next) {
323 if (!p->options.roundrobin)
324 continue;
325
326 if (neighborType(p, request->url) != PEER_PARENT)
327 continue;
328
329 if (!peerHTTPOkay(p, ps))
330 continue;
331
332 if (p->weight == 0)
333 continue;
334
335 if (q) {
336 if (p->weight == q->weight) {
337 if (q->rr_count < p->rr_count)
338 continue;
339 } else if ( ((double) q->rr_count / q->weight) < ((double) p->rr_count / p->weight)) {
340 continue;
341 }
342 }
343
344 q = p;
345 }
346
347 if (q)
348 ++ q->rr_count;
349
350 debugs(15, 3, "returning " << RawPointer(q).orNil());
351
352 return q;
353}
354
355CachePeer *
357{
358 assert(ps);
359 HttpRequest *request = ps->request;
360
361 CachePeer *p;
362 CachePeer *q = nullptr;
363 int weighted_rtt;
364
365 for (p = Config.peers; p; p = p->next) {
367 continue;
368
369 if (neighborType(p, request->url) != PEER_PARENT)
370 continue;
371
372 if (!peerHTTPOkay(p, ps))
373 continue;
374
375 if (q && q->rr_count < p->rr_count)
376 continue;
377
378 q = p;
379 }
380
381 if (q && q->rr_count > 1000000)
382 for (p = Config.peers; p; p = p->next) {
384 continue;
385
386 if (neighborType(p, request->url) != PEER_PARENT)
387 continue;
388
389 p->rr_count = 0;
390 }
391
392 if (q) {
393 weighted_rtt = (q->stats.rtt - q->basetime) / q->weight;
394
395 if (weighted_rtt < 1)
396 weighted_rtt = 1;
397
398 q->rr_count += weighted_rtt;
399
400 debugs(15, 3, "getWeightedRoundRobinParent: weighted_rtt " << weighted_rtt);
401 }
402
403 debugs(15, 3, "returning " << RawPointer(q).orNil());
404 return q;
405}
406
418static void
420{
421 peerClearRR();
422 eventAdd("peerClearRR", peerClearRRLoop, data, 5 * 60.0, 0);
423}
424
430void
432{
433 static bool event_added = false;
434 if (!event_added) {
435 peerClearRRLoop(nullptr);
436 event_added=true;
437 }
438}
439
447void
449{
450 CachePeer *p = nullptr;
451 for (p = Config.peers; p; p = p->next) {
452 p->rr_count = 1;
453 }
454}
455
456void
458{
459 if (p->stats.logged_state == PEER_DEAD && p->tcp_up) {
460 debugs(15, DBG_IMPORTANT, "Detected REVIVED " << neighborTypeStr(p) << ": " << *p);
462 peerClearRR();
463 if (p->standby.mgr.valid())
464 PeerPoolMgr::Checkpoint(p->standby.mgr, "revived peer");
465 }
466
468 p->stats.probe_start = 0;
469
470 // TODO: Remove or explain how we could detect an alive peer without IP addresses
471 if (!p->n_addresses)
473}
474
475CachePeer *
477{
478 assert(ps);
479 HttpRequest *request = ps->request;
480
481 CachePeer *p = nullptr;
482
483 for (p = Config.peers; p; p = p->next) {
484 if (neighborType(p, request->url) != PEER_PARENT)
485 continue;
486
487 if (!p->options.default_parent)
488 continue;
489
490 if (!peerHTTPOkay(p, ps))
491 continue;
492
493 debugs(15, 3, "returning " << *p);
494
495 return p;
496 }
497
498 // TODO: Refactor similar get*() functions to use our return/reporting style
499 debugs(15, 3, "none found");
500 return nullptr;
501}
502
503CachePeer *
505{
506 return p->next;
507}
508
509CachePeer *
511{
512 return Config.peers;
513}
514
515static void
517{
518 CachePeer *p = nullptr;
519 CachePeer **P = nullptr;
520 p = Config.peers;
521 P = &Config.peers;
522
523 while (p) {
524 if (target == p)
525 break;
526
527 P = &p->next;
528
529 p = p->next;
530 }
531
532 if (p) {
533 *P = p->next;
534 p->next = nullptr;
535 delete p;
536 --Config.npeers;
537 }
538
540}
541
542static void
544{
545 Mgr::RegisterAction("server_list",
546 "Peer Cache Statistics",
547 neighborDumpPeers, 0, 1);
548
550 Mgr::RegisterAction("non_peers",
551 "List of Unknown sites sending ICP messages",
553 }
554}
555
556void
558{
559 struct servent *sep = nullptr;
560 const char *me = getMyHostname();
561 CachePeer *thisPeer = nullptr;
562 CachePeer *next = nullptr;
563
565
567
568 for (thisPeer = Config.peers; thisPeer; thisPeer = next) {
569 next = thisPeer->next;
570
571 if (0 != strcmp(thisPeer->host, me))
572 continue;
573
574 for (AnyP::PortCfgPointer s = HttpPortList; s != nullptr; s = s->next) {
575 if (thisPeer->http_port != s->s.port())
576 continue;
577
578 debugs(15, DBG_IMPORTANT, "WARNING: Peer looks like this host." <<
579 Debug::Extra << "Ignoring cache_peer " << *thisPeer);
580
581 neighborRemove(thisPeer);
582 }
583 }
584 }
585
586 peerRefreshDNS((void *) 1);
587
588 sep = getservbyname("echo", "udp");
589 echo_port = sep ? ntohs((unsigned short) sep->s_port) : 7;
590
592}
593
594int
596 StoreEntry * entry,
597 IRCB * callback,
598 PeerSelector *ps,
599 int *exprep,
600 int *timeout)
601{
602 const char *url = entry->url();
603 MemObject *mem = entry->mem_obj;
604 CachePeer *p = nullptr;
605 int i;
606 int reqnum = 0;
607 int flags;
608 int queries_sent = 0;
609 int peers_pinged = 0;
610 int parent_timeout = 0, parent_exprep = 0;
611 int sibling_timeout = 0, sibling_exprep = 0;
612 int mcast_timeout = 0, mcast_exprep = 0;
613
614 if (Config.peers == nullptr)
615 return 0;
616
617 assert(!entry->hasDisk());
618
620
621 mem->ping_reply_callback = callback;
622
623 mem->ircb_data = ps;
624
625 reqnum = icpSetCacheKey((const cache_key *)entry->key);
626
627 for (i = 0, p = first_ping; i++ < Config.npeers; p = p->next) {
628 if (p == nullptr)
629 p = Config.peers;
630
631 debugs(15, 5, "candidate: " << *p);
632
633 if (!peerWouldBePinged(p, ps))
634 continue; /* next CachePeer */
635
636 ++peers_pinged;
637
638 debugs(15, 4, "pinging cache_peer " << *p << " for '" << url << "'");
639
640 debugs(15, 3, "neighborsUdpPing: key = '" << entry->getMD5Text() << "'");
641
642 debugs(15, 3, "neighborsUdpPing: reqnum = " << reqnum);
643
644#if USE_HTCP
645 if (p->options.htcp && !p->options.htcp_only_clr) {
646 if (Config.Port.htcp <= 0) {
647 debugs(15, DBG_CRITICAL, "ERROR: HTCP is disabled! Cannot send HTCP request to peer.");
648 continue;
649 }
650
651 debugs(15, 3, "neighborsUdpPing: sending HTCP query");
652 if (htcpQuery(entry, request, p) <= 0)
653 continue; // unable to send.
654 } else
655#endif
656 {
658 debugs(15, DBG_CRITICAL, "ERROR: ICP is disabled! Cannot send ICP request to peer.");
659 continue;
660 } else {
661
662 if (p->type == PEER_MULTICAST)
664
665 if (p->icp.port == echo_port) {
666 debugs(15, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping");
667 // TODO: Get ALE from callback_data if possible.
668 icpCreateAndSend(ICP_DECHO, 0, url, reqnum, 0,
669 icpOutgoingConn->fd, p->in_addr, nullptr);
670 } else {
671 flags = 0;
672
674 if (p->icp.version == ICP_VERSION_2)
675 flags |= ICP_FLAG_SRC_RTT;
676
677 // TODO: Get ALE from callback_data if possible.
678 icpCreateAndSend(ICP_QUERY, flags, url, reqnum, 0,
679 icpOutgoingConn->fd, p->in_addr, nullptr);
680 }
681 }
682 }
683
684 ++queries_sent;
685
686 ++ p->stats.pings_sent;
687
688 if (p->type == PEER_MULTICAST) {
689 mcast_exprep += p->mcast.n_replies_expected;
690 mcast_timeout += (p->stats.rtt * p->mcast.n_replies_expected);
691 } else if (neighborUp(p)) {
692 /* its alive, expect a reply from it */
693
694 if (neighborType(p, request->url) == PEER_PARENT) {
695 ++parent_exprep;
696 parent_timeout += p->stats.rtt;
697 } else {
698 ++sibling_exprep;
699 sibling_timeout += p->stats.rtt;
700 }
701 } else {
702 /* Neighbor is dead; ping it anyway, but don't expect a reply */
703 /* log it once at the threshold */
704
705 if (p->stats.logged_state == PEER_ALIVE) {
706 debugs(15, DBG_IMPORTANT, "Detected DEAD " << neighborTypeStr(p) << ": " << *p);
708 }
709 }
710
712
713 /*
714 * keep probe_start == 0 for a multicast CachePeer,
715 * so neighborUp() never says this CachePeer is dead.
716 */
717
718 if ((p->type != PEER_MULTICAST) && (p->stats.probe_start == 0))
720 }
721
722 if ((first_ping = first_ping->next) == nullptr)
724
725 /*
726 * How many replies to expect?
727 */
728 *exprep = parent_exprep + sibling_exprep + mcast_exprep;
729
730 /*
731 * If there is a configured timeout, use it
732 */
734 *timeout = Config.Timeout.icp_query;
735 else {
736 if (*exprep > 0) {
737 if (parent_exprep)
738 *timeout = 2 * parent_timeout / parent_exprep;
739 else if (mcast_exprep)
740 *timeout = 2 * mcast_timeout / mcast_exprep;
741 else
742 *timeout = 2 * sibling_timeout / sibling_exprep;
743 } else
744 *timeout = 2000; /* 2 seconds */
745
747 if (*timeout > Config.Timeout.icp_query_max)
748 *timeout = Config.Timeout.icp_query_max;
749
750 if (*timeout < Config.Timeout.icp_query_min)
751 *timeout = Config.Timeout.icp_query_min;
752 }
753
754 return peers_pinged;
755}
756
757/* lookup the digest of a given CachePeer */
760{
761#if USE_CACHE_DIGESTS
762 assert(ps);
763 HttpRequest *request = ps->request;
764 const cache_key *key = request ? storeKeyPublicByRequest(request) : nullptr;
765 assert(p);
766 assert(request);
767 debugs(15, 5, "cache_peer " << *p);
768 /* does the peeer have a valid digest? */
769
770 if (!p->digest) {
771 debugs(15, 5, "peerDigestLookup: gone!");
772 return LOOKUP_NONE;
773 } else if (!peerHTTPOkay(p, ps)) {
774 debugs(15, 5, "peerDigestLookup: !peerHTTPOkay");
775 return LOOKUP_NONE;
776 } else if (!p->digest->flags.needed) {
777 debugs(15, 5, "peerDigestLookup: note need");
779 return LOOKUP_NONE;
780 } else if (!p->digest->flags.usable) {
781 debugs(15, 5, "peerDigestLookup: !ready && " << (p->digest->flags.requested ? "" : "!") << "requested");
782 return LOOKUP_NONE;
783 }
784
785 debugs(15, 5, "OK to lookup cache_peer " << *p);
786 assert(p->digest->cd);
787 /* does digest predict a hit? */
788
789 if (!p->digest->cd->contains(key))
790 return LOOKUP_MISS;
791
792 debugs(15, 5, "HIT for cache_peer " << *p);
793
794 return LOOKUP_HIT;
795#else
796 (void)p;
797 (void)ps;
798#endif
799
800 return LOOKUP_NONE;
801}
802
803/* select best CachePeer based on cache digests */
804CachePeer *
806{
807 CachePeer *best_p = nullptr;
808#if USE_CACHE_DIGESTS
809 assert(ps);
810 HttpRequest *request = ps->request;
811
812 int best_rtt = 0;
813 int choice_count = 0;
814 int ichoice_count = 0;
815 CachePeer *p;
816 int p_rtt;
817 int i;
818
819 if (!request->flags.hierarchical)
820 return nullptr;
821
823
824 for (i = 0, p = first_ping; i++ < Config.npeers; p = p->next) {
825 lookup_t lookup;
826
827 if (!p)
828 p = Config.peers;
829
830 if (i == 1)
831 first_ping = p;
832
833 lookup = peerDigestLookup(p, ps);
834
835 if (lookup == LOOKUP_NONE)
836 continue;
837
838 ++choice_count;
839
840 if (lookup == LOOKUP_MISS)
841 continue;
842
843 p_rtt = netdbHostRtt(p->host);
844
845 debugs(15, 5, "cache_peer " << *p << " rtt: " << p_rtt);
846
847 /* is this CachePeer better than others in terms of rtt ? */
848 if (!best_p || (p_rtt && p_rtt < best_rtt)) {
849 best_p = p;
850 best_rtt = p_rtt;
851
852 if (p_rtt) /* informative choice (aka educated guess) */
853 ++ichoice_count;
854
855 debugs(15, 4, "cache_peer " << *p << " leads with rtt " << best_rtt);
856 }
857 }
858
859 debugs(15, 4, "neighborsDigestSelect: choices: " << choice_count << " (" << ichoice_count << ")");
860 peerNoteDigestLookup(request, best_p,
861 best_p ? LOOKUP_HIT : (choice_count ? LOOKUP_MISS : LOOKUP_NONE));
862 request->hier.n_choices = choice_count;
863 request->hier.n_ichoices = ichoice_count;
864#else
865 (void)ps;
866#endif
867
868 return best_p;
869}
870
871void
873{
874#if USE_CACHE_DIGESTS
875 if (p)
876 strncpy(request->hier.cd_host, p->host, sizeof(request->hier.cd_host)-1);
877 else
878 *request->hier.cd_host = '\0';
879
880 request->hier.cd_lookup = lookup;
881 debugs(15, 4, "cache_peer " << RawPointer(p).orNil() << ", lookup: " << lookup_t_str[lookup]);
882#else
883 (void)request;
884 (void)p;
885 (void)lookup;
886#endif
887}
888
889static void
890neighborAlive(CachePeer * p, const MemObject *, const icp_common_t * header)
891{
892 peerAlive(p);
893 ++ p->stats.pings_acked;
894
895 if ((icp_opcode) header->opcode <= ICP_END)
896 ++ p->icp.counts[header->opcode];
897
898 p->icp.version = (int) header->version;
899}
900
901static void
903{
904 int rtt, rtt_av_factor;
905
906 if (!mem)
907 return;
908
909 if (!mem->start_ping.tv_sec)
910 return;
911
912 rtt = tvSubMsec(mem->start_ping, current_time);
913
914 if (rtt < 1 || rtt > 10000)
915 return;
916
917 rtt_av_factor = RTT_AV_FACTOR;
918
920 rtt_av_factor = RTT_BACKGROUND_AV_FACTOR;
921
922 p->stats.rtt = Math::intAverage(p->stats.rtt, rtt, p->stats.pings_acked, rtt_av_factor);
923}
924
925#if USE_HTCP
926static void
928{
929 peerAlive(p);
930 ++ p->stats.pings_acked;
931 ++ p->htcp.counts[htcp->hit ? 1 : 0];
932 p->htcp.version = htcp->version;
933}
934
935#endif
936
937static void
939{
940 if (p == nullptr)
941 return;
942
944
945 ++NLateReplies;
946}
947
948static CachePeer *non_peers = nullptr;
949
950static void
952{
953 CachePeer *np;
954
955 for (np = non_peers; np; np = np->next) {
956 if (np->in_addr != from)
957 continue;
958
959 if (np->in_addr.port() != from.port())
960 continue;
961
962 break;
963 }
964
965 if (np == nullptr) {
966 char fromStr[MAX_IPSTRLEN];
967 from.toStr(fromStr, sizeof(fromStr));
968 np = new CachePeer(fromStr);
969 np->in_addr = from;
970 np->icp.port = from.port();
971 np->type = PEER_NONE;
972 np->next = non_peers;
973 non_peers = np;
974 }
975
976 ++ np->icp.counts[opcode];
977
978 if (isPowTen(++np->stats.ignored_replies))
979 debugs(15, DBG_IMPORTANT, "WARNING: Ignored " << np->stats.ignored_replies << " replies from non-peer " << *np);
980}
981
982/* ignoreMulticastReply
983 *
984 * * We want to ignore replies from multicast peers if the
985 * * cache_host_domain rules would normally prevent the CachePeer
986 * * from being used
987 */
988static int
990{
991 if (p == nullptr)
992 return 0;
993
994 if (!p->options.mcast_responder)
995 return 0;
996
997 if (peerHTTPOkay(p, ps))
998 return 0;
999
1000 return 1;
1001}
1002
1010void
1011neighborsUdpAck(const cache_key * key, icp_common_t * header, const Ip::Address &from)
1012{
1013 CachePeer *p = nullptr;
1014 StoreEntry *entry;
1015 MemObject *mem = nullptr;
1016 peer_t ntype = PEER_NONE;
1017 icp_opcode opcode = (icp_opcode) header->opcode;
1018
1019 debugs(15, 6, "neighborsUdpAck: opcode " << opcode << " '" << storeKeyText(key) << "'");
1020
1021 if ((entry = Store::Root().findCallbackXXX(key)))
1022 mem = entry->mem_obj;
1023
1024 if ((p = whichPeer(from)))
1025 neighborAlive(p, mem, header);
1026
1027 if (opcode > ICP_END)
1028 return;
1029
1030 const char *opcode_d = icp_opcode_str[opcode];
1031
1032 if (p)
1033 neighborUpdateRtt(p, mem);
1034
1035 /* Does the entry exist? */
1036 if (nullptr == entry) {
1037 debugs(12, 3, "neighborsUdpAck: Cache key '" << storeKeyText(key) << "' not found");
1039 return;
1040 }
1041
1042 /* check if someone is already fetching it */
1043 if (EBIT_TEST(entry->flags, ENTRY_DISPATCHED)) {
1044 debugs(15, 3, "neighborsUdpAck: '" << storeKeyText(key) << "' already being fetched.");
1046 return;
1047 }
1048
1049 if (mem == nullptr) {
1050 debugs(15, 2, "Ignoring " << opcode_d << " for missing mem_obj: " << storeKeyText(key));
1052 return;
1053 }
1054
1055 if (entry->ping_status != PING_WAITING) {
1056 debugs(15, 2, "neighborsUdpAck: Late " << opcode_d << " for " << storeKeyText(key));
1058 return;
1059 }
1060
1061 if (!entry->locked()) {
1062 // TODO: many entries are unlocked; why is this reported at level 1?
1063 debugs(12, DBG_IMPORTANT, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks");
1065 return;
1066 }
1067
1068 if (!mem->ircb_data) {
1069 debugs(12, DBG_IMPORTANT, "ERROR: Squid BUG: missing ICP callback data for " << *entry);
1071 return;
1072 }
1073
1074 debugs(15, 3, opcode_d << " for " << storeKeyText(key) << " from " << RawPointer(p).orNil("source"));
1075
1076 if (p) {
1077 ntype = neighborType(p, mem->request->url);
1078 }
1079
1080 if (ignoreMulticastReply(p, mem->ircb_data)) {
1082 } else if (opcode == ICP_MISS) {
1083 if (p == nullptr) {
1084 neighborIgnoreNonPeer(from, opcode);
1085 } else {
1086 mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1087 }
1088 } else if (opcode == ICP_HIT) {
1089 if (p == nullptr) {
1090 neighborIgnoreNonPeer(from, opcode);
1091 } else {
1092 header->opcode = ICP_HIT;
1093 mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1094 }
1095 } else if (opcode == ICP_DECHO) {
1096 if (p == nullptr) {
1097 neighborIgnoreNonPeer(from, opcode);
1098 } else if (ntype == PEER_SIBLING) {
1099 debug_trap("neighborsUdpAck: Found non-ICP cache as SIBLING\n");
1100 debug_trap("neighborsUdpAck: non-ICP neighbors must be a PARENT\n");
1101 } else {
1102 mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1103 }
1104 } else if (opcode == ICP_SECHO) {
1105 if (p) {
1106 debugs(15, DBG_IMPORTANT, "Ignoring SECHO from neighbor " << *p);
1108 } else {
1109 debugs(15, DBG_IMPORTANT, "Unsolicited SECHO from " << from);
1110 }
1111 } else if (opcode == ICP_DENIED) {
1112 if (p == nullptr) {
1113 neighborIgnoreNonPeer(from, opcode);
1114 } else if (p->stats.pings_acked > 100) {
1115 if (100 * p->icp.counts[ICP_DENIED] / p->stats.pings_acked > 95) {
1116 debugs(15, DBG_CRITICAL, "Disabling cache_peer " << *p <<
1117 " because over 95% of its replies are UDP_DENIED");
1118 neighborRemove(p);
1119 p = nullptr;
1120 } else {
1122 }
1123 }
1124 } else if (opcode == ICP_MISS_NOFETCH) {
1125 mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data);
1126 } else {
1127 debugs(15, DBG_CRITICAL, "ERROR: neighborsUdpAck: Unexpected ICP reply: " << opcode_d);
1128 }
1129}
1130
1131CachePeer *
1132findCachePeerByName(const char * const name)
1133{
1134 CachePeer *p = nullptr;
1135
1136 for (p = Config.peers; p; p = p->next) {
1137 if (!strcasecmp(name, p->name))
1138 break;
1139 }
1140
1141 return p;
1142}
1143
1144int
1146{
1147 if (!p->tcp_up) {
1148 peerProbeConnect(const_cast<CachePeer*>(p));
1149 return 0;
1150 }
1151
1152 /*
1153 * The CachePeer can not be UP if we don't have any IP addresses
1154 * for it.
1155 */
1156 if (0 == p->n_addresses) {
1157 debugs(15, 8, "DOWN (no-ip): " << *p);
1158 return 0;
1159 }
1160
1161 if (p->options.no_query) {
1162 debugs(15, 8, "UP (no-query): " << *p);
1163 return 1;
1164 }
1165
1166 if (p->stats.probe_start != 0 &&
1168 debugs(15, 8, "DOWN (dead): " << *p);
1169 return 0;
1170 }
1171
1172 debugs(15, 8, "UP: " << *p);
1173 return 1;
1174}
1175
1176time_t
1177positiveTimeout(const time_t timeout)
1178{
1179 return max(static_cast<time_t>(1), timeout);
1180}
1181
1182static void
1184{
1185 // TODO: connections to no-longer valid IP addresses should be
1186 // closed when we can detect such IP addresses.
1187
1188 CachePeer *p = (CachePeer *)data;
1189
1190 if (p->n_addresses == 0) {
1191 debugs(15, Important(29), "Configuring " << neighborTypeStr(p) << " " << *p);
1192
1193 if (p->type == PEER_MULTICAST)
1194 debugs(15, DBG_IMPORTANT, " Multicast TTL = " << p->mcast.ttl);
1195 }
1196
1197 p->n_addresses = 0;
1198
1199 if (ia == nullptr) {
1200 debugs(0, DBG_CRITICAL, "WARNING: DNS lookup for '" << *p << "' failed!");
1201 return;
1202 }
1203
1204 if (ia->empty()) {
1205 debugs(0, DBG_CRITICAL, "WARNING: No IP address found for '" << *p << "'!");
1206 return;
1207 }
1208
1209 for (const auto &ip: ia->goodAndBad()) { // TODO: Consider using just good().
1211 const auto idx = p->n_addresses++;
1212 p->addresses[idx] = ip;
1213 debugs(15, 2, "--> IP address #" << idx << ": " << p->addresses[idx]);
1214 } else {
1215 debugs(15, 3, "ignoring remaining " << (ia->size() - p->n_addresses) << " ips");
1216 break;
1217 }
1218 }
1219
1220 p->in_addr.setEmpty();
1221 p->in_addr = p->addresses[0];
1222 p->in_addr.port(p->icp.port);
1223
1224 peerProbeConnect(p, true); // detect any died or revived peers ASAP
1225
1226 if (p->type == PEER_MULTICAST)
1228
1229#if USE_ICMP
1230 if (p->type != PEER_MULTICAST && IamWorkerProcess())
1231 if (!p->options.no_netdb_exchange)
1232 eventAddIsh("netdbExchangeStart", netdbExchangeStart, p, 30.0, 1);
1233#endif
1234
1235 if (p->standby.mgr.valid())
1236 PeerPoolMgr::Checkpoint(p->standby.mgr, "resolved peer");
1237}
1238
1239static void
1241{
1242 CachePeer *p = nullptr;
1243
1244 if (eventFind(peerRefreshDNS, nullptr))
1245 eventDelete(peerRefreshDNS, nullptr);
1246
1247 if (!data && 0 == stat5minClientRequests()) {
1248 /* no recent client traffic, wait a bit */
1249 eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 180.0, 1);
1250 return;
1251 }
1252
1253 for (p = Config.peers; p; p = p->next)
1255
1256 /* Reconfigure the peers every hour */
1257 eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 3600.0, 1);
1258}
1259
1261static bool
1263{
1264 if (p->testing_now > 0) {
1265 debugs(15, 8, "yes, probing " << p);
1266 return true;
1267 }
1268 if (squid_curtime - p->stats.last_connect_probe == 0) {
1269 debugs(15, 8, "yes, just probed " << p);
1270 return true;
1271 }
1272 return false;
1273}
1274/*
1275* peerProbeConnect will be called on dead peers by neighborUp
1276*/
1277static void
1278peerProbeConnect(CachePeer *p, const bool reprobeIfBusy)
1279{
1280 if (peerProbeIsBusy(p)) {
1281 p->reprobe = reprobeIfBusy;
1282 return;
1283 }
1284 p->reprobe = false;
1285
1286 const auto ctimeout = p->connectTimeout();
1287 /* for each IP address of this CachePeer. find one that we can connect to and probe it. */
1288 for (int i = 0; i < p->n_addresses; ++i) {
1290 conn->remote = p->addresses[i];
1291 conn->remote.port(p->http_port);
1292 conn->setPeer(p);
1293 getOutgoingAddress(nullptr, conn);
1294
1295 ++ p->testing_now;
1296
1297 AsyncCall::Pointer call = commCbCall(15,3, "peerProbeConnectDone", CommConnectCbPtrFun(peerProbeConnectDone, p));
1298 Comm::ConnOpener *cs = new Comm::ConnOpener(conn, call, ctimeout);
1299 cs->setHost(p->host);
1300 AsyncJob::Start(cs);
1301 }
1302
1304}
1305
1306static void
1308{
1309 CachePeer *p = (CachePeer*)data;
1310
1311 if (status == Comm::OK)
1312 p->noteSuccess();
1313 else
1315
1316 -- p->testing_now;
1317 conn->close();
1318 // TODO: log this traffic.
1319
1320 if (p->reprobe)
1322}
1323
1324static void
1326{
1328 return;
1329
1330 eventAdd("peerCountMcastPeersStart",
1332 p,
1333 (double) when, 1);
1334
1336}
1337
1338static void
1340{
1341 const auto peer = static_cast<CachePeer*>(data);
1342 CallContextCreator([peer] {
1344 });
1346}
1347
1349static void
1351{
1352 // XXX: Do not create lots of complex fake objects (while abusing their
1353 // APIs) to pass around a few basic data points like start_ping and ping!
1354 MemObject *mem;
1355 int reqnum;
1356 // TODO: use class AnyP::Uri instead of constructing and re-parsing a string
1357 LOCAL_ARRAY(char, url, MAX_URL);
1358 assert(p->type == PEER_MULTICAST);
1359 p->mcast.flags.count_event_pending = false;
1360 snprintf(url, MAX_URL, "http://");
1361 p->in_addr.toUrl(url+7, MAX_URL -8 );
1362 strcat(url, "/");
1363 const auto mx = MasterXaction::MakePortless<XactionInitiator::initPeerMcast>();
1364 auto *req = HttpRequest::FromUrlXXX(url, mx);
1365 assert(req != nullptr);
1367 ale->request = req;
1368 CodeContext::Reset(ale);
1370 const auto psstate = new PeerSelector(nullptr);
1371 psstate->request = req;
1372 HTTPMSGLOCK(psstate->request);
1373 psstate->entry = fake;
1374 psstate->peerCountMcastPeerXXX = cbdataReference(p);
1375 psstate->ping.start = current_time;
1376 psstate->al = ale;
1377 mem = fake->mem_obj;
1378 mem->request = psstate->request;
1379 mem->start_ping = current_time;
1381 mem->ircb_data = psstate;
1383 p->mcast.id = mem->id;
1384 reqnum = icpSetCacheKey((const cache_key *)fake->key);
1385 icpCreateAndSend(ICP_QUERY, 0, url, reqnum, 0,
1386 icpOutgoingConn->fd, p->in_addr, psstate->al);
1387 fake->ping_status = PING_WAITING; // TODO: refactor to use PeerSelector::startPingWaiting()
1388 eventAdd("peerCountMcastPeersDone",
1390 psstate,
1391 Config.Timeout.mcast_icp_query / 1000.0, 1);
1392 p->mcast.flags.counting = true;
1393}
1394
1395static void
1397{
1398 const auto psstate = static_cast<PeerSelector*>(data);
1399 CallBack(psstate->al, [psstate] {
1400 peerCountMcastPeersAbort(psstate);
1401 delete psstate;
1402 });
1403}
1404
1407static void
1409{
1410 StoreEntry *fake = psstate->entry;
1411
1413 CachePeer *p = (CachePeer *)psstate->peerCountMcastPeerXXX;
1414 p->mcast.flags.counting = false;
1416 debugs(15, DBG_IMPORTANT, "Group " << *p << ": " << psstate->ping.n_recv <<
1417 " replies, "<< std::setw(4)<< std::setprecision(2) <<
1418 p->mcast.avg_n_members <<" average, RTT " << p->stats.rtt);
1420 }
1421
1423
1424 fake->abort(); // sets ENTRY_ABORTED and initiates related cleanup
1425 fake->mem_obj->request = nullptr;
1426 fake->unlock("peerCountMcastPeersDone");
1427}
1428
1429static void
1431{
1432 const auto psstate = static_cast<PeerSelector*>(data);
1433 StoreEntry *fake = psstate->entry;
1434 assert(fake);
1435 MemObject *mem = fake->mem_obj;
1436 assert(mem);
1437 int rtt = tvSubMsec(mem->start_ping, current_time);
1438 assert(proto == AnyP::PROTO_ICP);
1439 ++ psstate->ping.n_recv;
1440 int rtt_av_factor = RTT_AV_FACTOR;
1441
1443 rtt_av_factor = RTT_BACKGROUND_AV_FACTOR;
1444
1445 p->stats.rtt = Math::intAverage(p->stats.rtt, rtt, psstate->ping.n_recv, rtt_av_factor);
1446}
1447
1448static void
1450{
1451 dump_peers(sentry, Config.peers);
1452}
1453
1454static void
1456{
1457 dump_peers(sentry, non_peers);
1458}
1459
1460void
1462{
1463 if (p->options.proxy_only)
1464 storeAppendPrintf(sentry, " proxy-only");
1465
1466 if (p->options.no_query)
1467 storeAppendPrintf(sentry, " no-query");
1468
1469 if (p->options.background_ping)
1470 storeAppendPrintf(sentry, " background-ping");
1471
1472 if (p->options.no_digest)
1473 storeAppendPrintf(sentry, " no-digest");
1474
1475 if (p->options.default_parent)
1476 storeAppendPrintf(sentry, " default");
1477
1478 if (p->options.roundrobin)
1479 storeAppendPrintf(sentry, " round-robin");
1480
1481 if (p->options.carp)
1482 storeAppendPrintf(sentry, " carp");
1483
1484#if USE_AUTH
1485 if (p->options.userhash)
1486 storeAppendPrintf(sentry, " userhash");
1487#endif
1488
1489 if (p->options.sourcehash)
1490 storeAppendPrintf(sentry, " sourcehash");
1491
1493 storeAppendPrintf(sentry, " weighted-round-robin");
1494
1495 if (p->options.mcast_responder)
1496 storeAppendPrintf(sentry, " multicast-responder");
1497
1498#if PEER_MULTICAST_SIBLINGS
1499 if (p->options.mcast_siblings)
1500 storeAppendPrintf(sentry, " multicast-siblings");
1501#endif
1502
1503 if (p->weight != 1)
1504 storeAppendPrintf(sentry, " weight=%d", p->weight);
1505
1506 if (p->options.closest_only)
1507 storeAppendPrintf(sentry, " closest-only");
1508
1509#if USE_HTCP
1510 if (p->options.htcp) {
1511 storeAppendPrintf(sentry, " htcp");
1513 bool doneopts = false;
1514 if (p->options.htcp_oldsquid) {
1515 storeAppendPrintf(sentry, "oldsquid");
1516 doneopts = true;
1517 }
1518 if (p->options.htcp_no_clr) {
1519 storeAppendPrintf(sentry, "%sno-clr",(doneopts?",":"="));
1520 doneopts = true;
1521 }
1522 if (p->options.htcp_no_purge_clr) {
1523 storeAppendPrintf(sentry, "%sno-purge-clr",(doneopts?",":"="));
1524 doneopts = true;
1525 }
1526 if (p->options.htcp_only_clr) {
1527 storeAppendPrintf(sentry, "%sonly-clr",(doneopts?",":"="));
1528 //doneopts = true; // uncomment if more opts are added
1529 }
1530 }
1531 }
1532#endif
1533
1535 storeAppendPrintf(sentry, " no-netdb-exchange");
1536
1537#if USE_DELAY_POOLS
1538 if (p->options.no_delay)
1539 storeAppendPrintf(sentry, " no-delay");
1540#endif
1541
1542 if (p->login)
1543 storeAppendPrintf(sentry, " login=%s", p->login);
1544
1545 if (p->mcast.ttl > 0)
1546 storeAppendPrintf(sentry, " ttl=%d", p->mcast.ttl);
1547
1548 if (p->connect_timeout_raw > 0)
1549 storeAppendPrintf(sentry, " connect-timeout=%d", (int)p->connect_timeout_raw);
1550
1552 storeAppendPrintf(sentry, " connect-fail-limit=%d", p->connect_fail_limit);
1553
1554#if USE_CACHE_DIGESTS
1555
1556 if (p->digest_url)
1557 storeAppendPrintf(sentry, " digest-url=%s", p->digest_url);
1558
1559#endif
1560
1561 if (p->options.allow_miss)
1562 storeAppendPrintf(sentry, " allow-miss");
1563
1564 if (p->options.no_tproxy)
1565 storeAppendPrintf(sentry, " no-tproxy");
1566
1567 if (p->max_conn > 0)
1568 storeAppendPrintf(sentry, " max-conn=%d", p->max_conn);
1569 if (p->standby.limit > 0)
1570 storeAppendPrintf(sentry, " standby=%d", p->standby.limit);
1571
1572 if (p->options.originserver)
1573 storeAppendPrintf(sentry, " originserver");
1574
1575 if (p->domain)
1576 storeAppendPrintf(sentry, " forceddomain=%s", p->domain);
1577
1578 if (p->connection_auth == 0)
1579 storeAppendPrintf(sentry, " connection-auth=off");
1580 else if (p->connection_auth == 1)
1581 storeAppendPrintf(sentry, " connection-auth=on");
1582 else if (p->connection_auth == 2)
1583 storeAppendPrintf(sentry, " connection-auth=auto");
1584
1585 p->secure.dumpCfg(sentry,"tls-");
1586 storeAppendPrintf(sentry, "\n");
1587}
1588
1589static void
1591{
1592 char ntoabuf[MAX_IPSTRLEN];
1593 int i;
1594
1595 if (peers == nullptr)
1596 storeAppendPrintf(sentry, "There are no neighbors installed.\n");
1597
1598 for (CachePeer *e = peers; e; e = e->next) {
1599 assert(e->host != nullptr);
1600 storeAppendPrintf(sentry, "\n%-11.11s: %s\n",
1601 neighborTypeStr(e),
1602 e->name);
1603 storeAppendPrintf(sentry, "Host : %s/%d/%d\n",
1604 e->host,
1605 e->http_port,
1606 e->icp.port);
1607 storeAppendPrintf(sentry, "Flags :");
1608 dump_peer_options(sentry, e);
1609
1610 for (i = 0; i < e->n_addresses; ++i) {
1611 storeAppendPrintf(sentry, "Address[%d] : %s\n", i,
1612 e->addresses[i].toStr(ntoabuf,MAX_IPSTRLEN) );
1613 }
1614
1615 storeAppendPrintf(sentry, "Status : %s\n",
1616 neighborUp(e) ? "Up" : "Down");
1617 storeAppendPrintf(sentry, "FETCHES : %d\n", e->stats.fetches);
1618 storeAppendPrintf(sentry, "OPEN CONNS : %d\n", e->stats.conn_open);
1619 storeAppendPrintf(sentry, "AVG RTT : %d msec\n", e->stats.rtt);
1620
1621 if (!e->options.no_query) {
1622 storeAppendPrintf(sentry, "LAST QUERY : %8d seconds ago\n",
1623 (int) (squid_curtime - e->stats.last_query));
1624
1625 if (e->stats.last_reply > 0)
1626 storeAppendPrintf(sentry, "LAST REPLY : %8d seconds ago\n",
1627 (int) (squid_curtime - e->stats.last_reply));
1628 else
1629 storeAppendPrintf(sentry, "LAST REPLY : none received\n");
1630
1631 storeAppendPrintf(sentry, "PINGS SENT : %8d\n", e->stats.pings_sent);
1632
1633 storeAppendPrintf(sentry, "PINGS ACKED: %8d %3d%%\n",
1634 e->stats.pings_acked,
1635 Math::intPercent(e->stats.pings_acked, e->stats.pings_sent));
1636 }
1637
1638 storeAppendPrintf(sentry, "IGNORED : %8d %3d%%\n", e->stats.ignored_replies, Math::intPercent(e->stats.ignored_replies, e->stats.pings_acked));
1639
1640 if (!e->options.no_query) {
1641 storeAppendPrintf(sentry, "Histogram of PINGS ACKED:\n");
1642#if USE_HTCP
1643
1644 if (e->options.htcp) {
1645 storeAppendPrintf(sentry, "\tMisses\t%8d %3d%%\n",
1646 e->htcp.counts[0],
1647 Math::intPercent(e->htcp.counts[0], e->stats.pings_acked));
1648 storeAppendPrintf(sentry, "\tHits\t%8d %3d%%\n",
1649 e->htcp.counts[1],
1650 Math::intPercent(e->htcp.counts[1], e->stats.pings_acked));
1651 } else {
1652#endif
1653
1654 for (auto op : WholeEnum<icp_opcode>()) {
1655 if (e->icp.counts[op] == 0)
1656 continue;
1657
1658 storeAppendPrintf(sentry, " %12.12s : %8d %3d%%\n",
1659 icp_opcode_str[op],
1660 e->icp.counts[op],
1661 Math::intPercent(e->icp.counts[op], e->stats.pings_acked));
1662 }
1663
1664#if USE_HTCP
1665
1666 }
1667
1668#endif
1669
1670 }
1671
1672 if (e->stats.last_connect_failure) {
1673 storeAppendPrintf(sentry, "Last failed connect() at: %s\n",
1674 Time::FormatHttpd(e->stats.last_connect_failure));
1675 }
1676
1677 storeAppendPrintf(sentry, "keep-alive ratio: %d%%\n", Math::intPercent(e->stats.n_keepalives_recv, e->stats.n_keepalives_sent));
1678 }
1679}
1680
1681#if USE_HTCP
1682void
1684{
1686 MemObject *mem = nullptr;
1687 CachePeer *p;
1688 peer_t ntype = PEER_NONE;
1689 debugs(15, 6, "neighborsHtcpReply: " <<
1690 (htcp->hit ? "HIT" : "MISS") << " " <<
1691 storeKeyText(key) );
1692
1693 if (nullptr != e)
1694 mem = e->mem_obj;
1695
1696 if ((p = whichPeer(from)))
1697 neighborAliveHtcp(p, mem, htcp);
1698
1699 /* Does the entry exist? */
1700 if (nullptr == e) {
1701 debugs(12, 3, "neighyborsHtcpReply: Cache key '" << storeKeyText(key) << "' not found");
1703 return;
1704 }
1705
1706 /* check if someone is already fetching it */
1707 if (EBIT_TEST(e->flags, ENTRY_DISPATCHED)) {
1708 debugs(15, 3, "neighborsUdpAck: '" << storeKeyText(key) << "' already being fetched.");
1710 return;
1711 }
1712
1713 if (mem == nullptr) {
1714 debugs(15, 2, "Ignoring reply for missing mem_obj: " << storeKeyText(key));
1716 return;
1717 }
1718
1719 if (e->ping_status != PING_WAITING) {
1720 debugs(15, 2, "neighborsUdpAck: Entry " << storeKeyText(key) << " is not PING_WAITING");
1722 return;
1723 }
1724
1725 if (!e->locked()) {
1726 // TODO: many entries are unlocked; why is this reported at level 1?
1727 debugs(12, DBG_IMPORTANT, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks");
1729 return;
1730 }
1731
1732 if (!mem->ircb_data) {
1733 debugs(12, DBG_IMPORTANT, "ERROR: Squid BUG: missing HTCP callback data for " << *e);
1735 return;
1736 }
1737
1738 if (p) {
1739 ntype = neighborType(p, mem->request->url);
1740 neighborUpdateRtt(p, mem);
1741 }
1742
1743 if (ignoreMulticastReply(p, mem->ircb_data)) {
1745 return;
1746 }
1747
1748 debugs(15, 3, "neighborsHtcpReply: e = " << e);
1749 // TODO: Refactor (ping_reply_callback,ircb_data) to add CodeContext.
1750 mem->ping_reply_callback(p, ntype, AnyP::PROTO_HTCP, htcp, mem->ircb_data);
1751}
1752
1753/*
1754 * Send HTCP CLR messages to all peers configured to receive them.
1755 */
1756void
1758{
1759 CachePeer *p;
1760 char buf[128];
1761
1762 for (p = Config.peers; p; p = p->next) {
1763 if (!p->options.htcp) {
1764 continue;
1765 }
1766 if (p->options.htcp_no_clr) {
1767 continue;
1768 }
1769 if (p->options.htcp_no_purge_clr && reason == HTCP_CLR_PURGE) {
1770 continue;
1771 }
1772 debugs(15, 3, "neighborsHtcpClear: sending CLR to " << p->in_addr.toUrl(buf, 128));
1773 htcpClear(e, req, method, p, reason);
1774 }
1775}
1776
1777#endif
1778
void CallContextCreator(Fun &&creator)
Definition: CodeContext.h:148
void CallBack(const CodeContext::Pointer &callbackContext, Fun &&callback)
Definition: CodeContext.h:116
CommCbFunPtrCallT< Dialer > * commCbCall(int debugSection, int debugLevel, const char *callName, const Dialer &dialer)
Definition: CommCalls.h:312
void CNCB(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data)
Definition: CommCalls.h:33
void getOutgoingAddress(HttpRequest *request, const Comm::ConnectionPointer &conn)
Definition: FwdState.cc:1484
RawPointerT< Pointer > RawPointer(const char *label, const Pointer &ptr)
convenience wrapper for creating RawPointerT<> objects
Definition: IoManip.h:43
time_t squid_curtime
Definition: stub_libtime.cc:20
AnyP::PortCfgPointer HttpPortList
list of Squid http(s)_port configured
Definition: PortCfg.cc:22
class SquidConfig Config
Definition: SquidConfig.cc:12
int conn
the current server connection FD
Definition: Transport.cc:26
int matchDomainName(const char *h, const char *d, MatchDomainNameFlags flags)
Definition: Uri.cc:736
#define assert(EX)
Definition: assert.h:17
int cbdataReferenceValid(const void *p)
Definition: cbdata.cc:265
#define cbdataReferenceDone(var)
Definition: cbdata.h:352
#define cbdataReference(var)
Definition: cbdata.h:343
Acl::Answer const & fastCheck()
Definition: Checklist.cc:332
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
HttpReplyPointer reply
HttpRequest * request
bool allowed() const
Definition: Acl.h:156
Definition: Uri.h:31
SBuf & authority(bool requirePort=false) const
Definition: Uri.cc:566
void port(unsigned short p)
Definition: Uri.h:94
void host(const char *src)
Definition: Uri.cc:99
static void Start(const Pointer &job)
Definition: AsyncJob.cc:24
bool contains(const cache_key *key) const
Definition: CacheDigest.cc:93
CbcPointer< PeerPoolMgr > mgr
pool manager
Definition: CachePeer.h:213
acl_access * access
Definition: CachePeer.h:106
bool closest_only
Definition: CachePeer.h:117
int weight
Definition: CachePeer.h:152
bool no_tproxy
Definition: CachePeer.h:145
void noteSuccess()
reacts to a successful establishment of a connection to this cache_peer
Definition: CachePeer.cc:60
bool htcp_oldsquid
Definition: CachePeer.h:120
bool no_query
Definition: CachePeer.h:110
NeighborTypeDomainList * typelist
Definition: CachePeer.h:105
int basetime
Definition: CachePeer.h:153
bool originserver
Definition: CachePeer.h:144
time_t probe_start
Definition: CachePeer.h:80
bool background_ping
Definition: CachePeer.h:111
peer_t type
Definition: CachePeer.h:68
bool roundrobin
Definition: CachePeer.h:114
int n_addresses
Definition: CachePeer.h:182
int connection_auth
0 - off, 1 - on, 2 - auto
Definition: CachePeer.h:226
unsigned short http_port
Definition: CachePeer.h:104
bool proxy_only
Definition: CachePeer.h:109
int pings_sent
Definition: CachePeer.h:73
int logged_state
so we can print dead/revived msgs
Definition: CachePeer.h:85
char * login
Definition: CachePeer.h:205
time_t last_connect_probe
Definition: CachePeer.h:84
bool htcp_no_purge_clr
Definition: CachePeer.h:122
char * host
Definition: CachePeer.h:66
Security::PeerOptions secure
security settings for peer connection
Definition: CachePeer.h:221
time_t connect_timeout_raw
connect_timeout; use connectTimeout() instead!
Definition: CachePeer.h:206
bool mcast_siblings
Definition: CachePeer.h:147
char * domain
Forced domain.
Definition: CachePeer.h:218
int limit
the limit itself
Definition: CachePeer.h:214
time_t last_query
Definition: CachePeer.h:81
CachePeer * next
Definition: CachePeer.h:184
PeerDigest * digest
Definition: CachePeer.h:169
int n_replies_expected
Definition: CachePeer.h:158
int tcp_up
Definition: CachePeer.h:176
bool counting
Definition: CachePeer.h:164
int rtt
Definition: CachePeer.h:76
bool no_digest
Definition: CachePeer.h:112
Ip::Address in_addr
Definition: CachePeer.h:70
PconnPool * pool
idle connection pool for this peer
Definition: CachePeer.h:212
int rr_count
Definition: CachePeer.h:183
bool waitingForClose
a conn must close before we open a standby conn
Definition: CachePeer.h:215
bool sourcehash
Definition: CachePeer.h:143
int connect_fail_limit
Definition: CachePeer.h:207
double avg_n_members
Definition: CachePeer.h:156
int n_times_counted
Definition: CachePeer.h:157
struct CachePeer::icp_ icp
time_t last_reply
Definition: CachePeer.h:82
int pings_acked
Definition: CachePeer.h:74
bool no_netdb_exchange
Definition: CachePeer.h:126
int max_conn
Definition: CachePeer.h:208
struct CachePeer::@30 mcast
struct CachePeer::@28 htcp
bool htcp_only_clr
Definition: CachePeer.h:123
struct CachePeer::@27 stats
time_t connectTimeout() const
Definition: CachePeer.cc:118
struct CachePeer::@29 options
int counts[2]
Definition: CachePeer.h:99
bool count_event_pending
Definition: CachePeer.h:163
char * name
Definition: CachePeer.h:60
Ip::Address addresses[10]
Definition: CachePeer.h:181
bool userhash
Definition: CachePeer.h:141
int conn_open
current opened connections
Definition: CachePeer.h:86
int testing_now
Definition: CachePeer.h:185
bool default_parent
Definition: CachePeer.h:113
bool carp
Definition: CachePeer.h:131
bool reprobe
whether to do another TCP probe after current TCP probes
Definition: CachePeer.h:179
bool allow_miss
Definition: CachePeer.h:130
char * digest_url
Definition: CachePeer.h:170
int ignored_replies
Definition: CachePeer.h:77
double version
Definition: CachePeer.h:98
struct CachePeer::@30::@36 flags
void noteFailure(Http::StatusCode code)
Definition: CachePeer.cc:72
bool mcast_responder
Definition: CachePeer.h:116
struct CachePeer::@34 standby
optional "cache_peer standby=limit" feature
bool weighted_roundrobin
Definition: CachePeer.h:115
bool htcp_no_clr
Definition: CachePeer.h:121
bool no_delay
Definition: CachePeer.h:128
Cbc * valid() const
was set and is valid
Definition: CbcPointer.h:41
static void Reset()
forgets the current context, setting it to nil/unknown
Definition: CodeContext.cc:77
void setHost(const char *)
set the hostname note for this connection
Definition: ConnOpener.cc:100
static std::ostream & Extra(std::ostream &os)
prefixes each grouped debugs() line after the first one in the group
Definition: Stream.h:114
size_t size() const noexcept
all cached IPs
Definition: ipcache.h:62
IpsSelector< IpsIterator > goodAndBad() const
all IPs
Definition: ipcache.h:248
bool empty() const noexcept
whether we cached no IPs at all
Definition: ipcache.h:61
encapsulates DNS lookup results
Definition: LookupDetails.h:21
char cd_host[SQUIDHOSTNAMELEN]
double version
Definition: htcp.h:32
int hit
Definition: htcp.h:29
HttpRequestMethod method
Definition: HttpRequest.h:114
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:528
HierarchyLogEntry hier
Definition: HttpRequest.h:157
RequestFlags flags
Definition: HttpRequest.h:141
AnyP::Uri url
the request URI
Definition: HttpRequest.h:115
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
Definition: Address.cc:792
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
Definition: Address.cc:184
char * toUrl(char *buf, unsigned int len) const
Definition: Address.cc:874
unsigned short port() const
Definition: Address.cc:778
IRCB * ping_reply_callback
Definition: MemObject.h:191
HttpRequestPointer request
Definition: MemObject.h:188
struct timeval start_ping
Definition: MemObject.h:190
PeerSelector * ircb_data
Definition: MemObject.h:192
representation of a neighbor_type_domain configuration directive. A POD
NeighborTypeDomainList * next
void count(int uses)
bool requested
Definition: PeerDigest.h:90
bool usable
Definition: PeerDigest.h:89
bool needed
Definition: PeerDigest.h:88
CacheDigest * cd
Definition: PeerDigest.h:83
struct PeerDigest::@84 flags
static void Checkpoint(const Pointer &mgr, const char *reason)
Definition: PeerPoolMgr.cc:228
HttpRequest * request
AccessLogEntry::Pointer al
info for the future access.log entry
void * peerCountMcastPeerXXX
a hack to help peerCountMcastPeersStart()
ping_data ping
StoreEntry * entry
C * getRaw() const
Definition: RefCount.h:80
bool needValidation
Definition: RequestFlags.h:50
bool loopDetected
Definition: RequestFlags.h:40
bool hierarchical
Definition: RequestFlags.h:38
virtual void dumpCfg(Packable *, const char *pfx) const
output squid.conf syntax with 'pfx' prefix on parameters for the stored settings
Definition: PeerOptions.cc:105
struct SquidConfig::@94 Port
time_t deadPeer
Definition: SquidConfig.h:122
int mcast_icp_query
Definition: SquidConfig.h:127
struct SquidConfig::@106 onoff
int icp_query_max
Definition: SquidConfig.h:125
int icp_query_min
Definition: SquidConfig.h:126
CachePeer * peers
Definition: SquidConfig.h:245
unsigned short icp
Definition: SquidConfig.h:139
struct SquidConfig::@93 Timeout
time_t backgroundPingRate
Definition: SquidConfig.h:106
unsigned short htcp
Definition: SquidConfig.h:142
uint16_t flags
Definition: Store.h:232
int locked() const
Definition: Store.h:146
int unlock(const char *context)
Definition: store.cc:443
const char * url() const
Definition: store.cc:1534
bool hasDisk(const sdirno dirn=-1, const sfileno filen=-1) const
Definition: store.cc:1897
const char * getMD5Text() const
Definition: store.cc:205
MemObject * mem_obj
Definition: Store.h:221
ping_status_t ping_status
Definition: Store.h:242
void abort()
Definition: store.cc:1051
StoreEntry * findCallbackXXX(const cache_key *)
Definition: Controller.cc:395
unsigned char version
Definition: ICP.h:40
unsigned char opcode
Definition: ICP.h:38
int n_recv
Definition: PingData.h:39
A const & max(A const &lhs, A const &rhs)
#define Important(id)
Definition: Messages.h:91
#define DBG_IMPORTANT
Definition: Stream.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:193
#define DBG_CRITICAL
Definition: Stream.h:37
#define RTT_BACKGROUND_AV_FACTOR
Definition: defines.h:83
#define PEER_TCP_MAGIC_COUNT
Definition: defines.h:124
#define PEER_MAX_ADDRESSES
Definition: defines.h:81
#define ICP_FLAG_SRC_RTT
Definition: defines.h:41
#define PEER_ALIVE
Definition: defines.h:86
#define PEER_DEAD
Definition: defines.h:85
#define ICP_VERSION_2
Definition: defines.h:44
#define EBIT_TEST(flag, bit)
Definition: defines.h:69
#define RTT_AV_FACTOR
Definition: defines.h:82
#define MAX_URL
Definition: defines.h:78
@ PING_WAITING
Sent ICP queries to peers and still awaiting responses.
Definition: enums.h:43
htcp_clr_reason
Definition: enums.h:241
@ HTCP_CLR_PURGE
Definition: enums.h:242
peer_t
Definition: enums.h:27
@ PEER_SIBLING
Definition: enums.h:29
@ PEER_PARENT
Definition: enums.h:30
@ PEER_NONE
Definition: enums.h:28
@ PEER_MULTICAST
Definition: enums.h:31
@ ENTRY_DISPATCHED
Definition: enums.h:101
void eventAddIsh(const char *name, EVH *func, void *arg, double delta_ish, int weight)
Definition: event.cc:114
int eventFind(EVH *func, void *arg)
Definition: event.cc:145
void eventDelete(EVH *func, void *arg)
Definition: event.cc:127
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
Definition: event.cc:107
int Squid_MaxFD
void ipcache_nbgethostbyname(const char *name, IPH *handler, void *handlerData)
Definition: ipcache.cc:599
int icpSetCacheKey(const cache_key *key)
Definition: icp_v2.cc:861
void icpCreateAndSend(icp_opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from, AccessLogEntryPointer)
Definition: icp_v2.cc:418
icp_opcode
Definition: icp_opcode.h:13
@ ICP_DECHO
Definition: icp_opcode.h:26
@ ICP_QUERY
Definition: icp_opcode.h:16
@ ICP_MISS_NOFETCH
Definition: icp_opcode.h:36
@ ICP_END
Definition: icp_opcode.h:39
@ ICP_DENIED
Definition: icp_opcode.h:37
@ ICP_SECHO
Definition: icp_opcode.h:25
@ ICP_MISS
Definition: icp_opcode.h:18
@ ICP_HIT
Definition: icp_opcode.h:17
Comm::ConnectionPointer icpOutgoingConn
Definition: icp_v2.cc:101
Comm::ConnectionPointer icpIncomingConn
Definition: icp_v2.cc:99
int htcpQuery(StoreEntry *e, HttpRequest *req, CachePeer *p)
Definition: htcp.cc:1516
void htcpClear(StoreEntry *e, HttpRequest *req, const HttpRequestMethod &, CachePeer *p, htcp_clr_reason reason)
Definition: htcp.cc:1565
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:160
const char * icp_opcode_str[]
int isPowTen(int count)
Definition: int.cc:17
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
Definition: forward.h:25
void IPH(const ipcache_addrs *, const Dns::LookupDetails &details, void *)
Definition: ipcache.h:226
const char * lookup_t_str[]
lookup_t
Definition: lookup_t.h:12
@ LOOKUP_MISS
Definition: lookup_t.h:15
@ LOOKUP_HIT
Definition: lookup_t.h:14
@ LOOKUP_NONE
Definition: lookup_t.h:13
void OBJH(StoreEntry *)
Definition: forward.h:44
int mcastSetTtl(int fd, int mcast_ttl)
Definition: multicast.cc:20
ProtocolType
Definition: ProtocolType.h:23
@ PROTO_HTCP
Definition: ProtocolType.h:34
@ PROTO_ICP
Definition: ProtocolType.h:32
bool IsConnOpen(const Comm::ConnectionPointer &conn)
Definition: Connection.cc:27
Flag
Definition: Flag.h:15
@ OK
Definition: Flag.h:16
@ scNone
Definition: StatusCode.h:21
@ METHOD_CONNECT
Definition: MethodType.h:29
@ METHOD_GET
Definition: MethodType.h:25
int intPercent(const int a, const int b)
Definition: SquidMath.cc:13
double doubleAverage(const double, const double, int, const int)
Definition: SquidMath.cc:31
int intAverage(const int, const int, int, const int)
Definition: SquidMath.cc:40
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
SSL Connection
Definition: Session.h:45
Controller & Root()
safely access controller singleton
Definition: Controller.cc:931
const char * FormatHttpd(time_t)
Definition: gadgets.cc:116
static OBJH neighborDumpNonPeers
Definition: neighbors.cc:73
static void peerClearRRLoop(void *data)
Definition: neighbors.cc:419
static void peerCountMcastPeersDone(void *data)
Definition: neighbors.cc:1396
void peerNoteDigestLookup(HttpRequest *request, CachePeer *p, lookup_t lookup)
Definition: neighbors.cc:872
static int peerWouldBePinged(const CachePeer *, PeerSelector *)
Definition: neighbors.cc:184
static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *)
Definition: neighbors.cc:927
static void peerCountMcastPeersSchedule(CachePeer *p, time_t when)
Definition: neighbors.cc:1325
void neighborsHtcpClear(StoreEntry *e, HttpRequest *req, const HttpRequestMethod &method, htcp_clr_reason reason)
Definition: neighbors.cc:1757
CachePeer * getFirstUpParent(PeerSelector *ps)
Definition: neighbors.cc:289
CachePeer * findCachePeerByName(const char *const name)
cache_peer with a given name (or nil)
Definition: neighbors.cc:1132
static IPH peerDNSConfigure
Definition: neighbors.cc:61
CachePeer * whichPeer(const Ip::Address &from)
Definition: neighbors.cc:97
static CachePeer * first_ping
Definition: neighbors.cc:79
static void peerCountMcastPeersCreateAndSend(CachePeer *p)
initiates an ICP transaction to a multicast peer
Definition: neighbors.cc:1350
void neighborsHtcpReply(const cache_key *key, HtcpReplyData *htcp, const Ip::Address &from)
Definition: neighbors.cc:1683
static void neighborUpdateRtt(CachePeer *p, MemObject *mem)
Definition: neighbors.cc:902
static CNCB peerProbeConnectDone
Definition: neighbors.cc:63
void peerAlive(CachePeer *p)
Definition: neighbors.cc:457
void peerClearRR()
Definition: neighbors.cc:448
void neighbors_init(void)
Definition: neighbors.cc:557
static OBJH neighborDumpPeers
Definition: neighbors.cc:72
bool peerHasConnAvailable(const CachePeer *p)
Whether the peer has idle or standby connections that can be used now.
Definition: neighbors.cc:233
int neighborsCount(PeerSelector *ps)
Definition: neighbors.cc:274
static void peerCountMcastPeersAbort(PeerSelector *)
Definition: neighbors.cc:1408
void dump_peer_options(StoreEntry *sentry, CachePeer *p)
Definition: neighbors.cc:1461
int neighborUp(const CachePeer *p)
Definition: neighbors.cc:1145
static bool peerProbeIsBusy(const CachePeer *p)
whether new TCP probes are currently banned
Definition: neighbors.cc:1262
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
Definition: neighbors.cc:259
CachePeer * getDefaultParent(PeerSelector *ps)
Definition: neighbors.cc:476
CachePeer * getRoundRobinParent(PeerSelector *ps)
Definition: neighbors.cc:314
const char * neighborTypeStr(const CachePeer *p)
Definition: neighbors.cc:82
time_t positiveTimeout(const time_t timeout)
Definition: neighbors.cc:1177
bool peerAllowedToUse(const CachePeer *, PeerSelector *)
Definition: neighbors.cc:139
static void neighborsRegisterWithCacheManager()
Definition: neighbors.cc:543
void peerClearRRStart(void)
Definition: neighbors.cc:431
bool peerCanOpenMore(const CachePeer *p)
Whether we can open new connections to the peer (e.g., despite max-conn)
Definition: neighbors.cc:224
static int NLateReplies
Definition: neighbors.cc:78
peer_t neighborType(const CachePeer *p, const AnyP::Uri &url)
Definition: neighbors.cc:116
static void dump_peers(StoreEntry *sentry, CachePeer *peers)
Definition: neighbors.cc:1590
int neighborsUdpPing(HttpRequest *request, StoreEntry *entry, IRCB *callback, PeerSelector *ps, int *exprep, int *timeout)
Definition: neighbors.cc:595
CachePeer * neighborsDigestSelect(PeerSelector *ps)
Definition: neighbors.cc:805
static CachePeer * non_peers
Definition: neighbors.cc:948
static IRCB peerCountHandleIcpReply
Definition: neighbors.cc:69
static unsigned short echo_port
Definition: neighbors.cc:76
static void peerRefreshDNS(void *)
Definition: neighbors.cc:1240
static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *)
Definition: neighbors.cc:890
CachePeer * getNextPeer(CachePeer *p)
Definition: neighbors.cc:504
lookup_t peerDigestLookup(CachePeer *p, PeerSelector *ps)
Definition: neighbors.cc:759
#define MCAST_COUNT_RATE
Definition: neighbors.cc:50
CachePeer * getFirstPeer(void)
Definition: neighbors.cc:510
static void neighborCountIgnored(CachePeer *)
Definition: neighbors.cc:938
void peerConnClosed(CachePeer *p)
Notifies peer of an associated connection closure.
Definition: neighbors.cc:248
static void neighborIgnoreNonPeer(const Ip::Address &, icp_opcode)
Definition: neighbors.cc:951
static int ignoreMulticastReply(CachePeer *p, PeerSelector *ps)
Definition: neighbors.cc:989
void neighborsUdpAck(const cache_key *key, icp_common_t *header, const Ip::Address &from)
Definition: neighbors.cc:1011
static void neighborRemove(CachePeer *)
Definition: neighbors.cc:516
static void peerProbeConnect(CachePeer *, const bool reprobeIfBusy=false)
Definition: neighbors.cc:1278
CachePeer * getWeightedRoundRobinParent(PeerSelector *ps)
Definition: neighbors.cc:356
static void peerCountMcastPeersStart(void *data)
Definition: neighbors.cc:1339
int netdbHostRtt(const char *host)
Definition: net_db.cc:1020
void netdbExchangeStart(void *data)
Definition: net_db.cc:1257
struct servent * getservbyname()
void peerDigestNeeded(PeerDigest *pd)
Definition: peer_digest.cc:176
#define LOCAL_ARRAY(type, name, size)
Definition: squid.h:68
int stat5minClientRequests(void)
Definition: stat.cc:1687
unsigned char cache_key
Store key.
Definition: forward.h:29
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:829
StoreEntry * storeCreateEntry(const char *url, const char *logUrl, const RequestFlags &flags, const HttpRequestMethod &method)
Definition: store.cc:733
const cache_key * storeKeyPublicByRequest(HttpRequest *request, const KeyScope keyScope)
const char * storeKeyText(const cache_key *key)
unsigned short port
Definition: CachePeer.h:93
int counts[ICP_END+1]
Definition: CachePeer.h:92
int unsigned int
Definition: stub_fd.cc:19
bool IamWorkerProcess()
whether the current process handles HTTP transactions and such
Definition: stub_tools.cc:47
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:17
int tvSubMsec(struct timeval t1, struct timeval t2)
Definition: gadgets.cc:51
const char * getMyHostname(void)
Definition: tools.cc:467
void debug_trap(const char *message)
Definition: tools.cc:458
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors