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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors