neighbors.cc File Reference
#include "squid.h"
#include "acl/FilledChecklist.h"
#include "anyp/PortCfg.h"
#include "base/EnumIterator.h"
#include "CacheDigest.h"
#include "CachePeer.h"
#include "comm/Connection.h"
#include "comm/ConnOpener.h"
#include "event.h"
#include "FwdState.h"
#include "globals.h"
#include "htcp.h"
#include "HttpRequest.h"
#include "icmp/net_db.h"
#include "ICP.h"
#include "int.h"
#include "ip/Address.h"
#include "ip/tools.h"
#include "ipcache.h"
#include "MemObject.h"
#include "mgr/Registration.h"
#include "multicast.h"
#include "neighbors.h"
#include "NeighborTypeDomainList.h"
#include "pconn.h"
#include "PeerDigest.h"
#include "PeerPoolMgr.h"
#include "PeerSelectState.h"
#include "RequestFlags.h"
#include "SquidConfig.h"
#include "SquidMath.h"
#include "SquidTime.h"
#include "stat.h"
#include "Store.h"
#include "store_key_md5.h"
#include "tools.h"
Include dependency graph for neighbors.cc:

Go to the source code of this file.

Macros

#define MCAST_COUNT_RATE   900
 

Functions

bool peerAllowedToUse (const CachePeer *, PeerSelector *)
 
static int peerWouldBePinged (const CachePeer *, PeerSelector *)
 
static void neighborRemove (CachePeer *)
 
static void neighborAlive (CachePeer *, const MemObject *, const icp_common_t *)
 
static void neighborAliveHtcp (CachePeer *, const MemObject *, const HtcpReplyData *)
 
static void neighborCountIgnored (CachePeer *)
 
static void peerRefreshDNS (void *)
 
static void peerProbeConnect (CachePeer *, const bool reprobeIfBusy=false)
 
static void peerCountMcastPeersDone (void *data)
 
static void peerCountMcastPeersStart (void *data)
 
static void peerCountMcastPeersSchedule (CachePeer *p, time_t when)
 
static void neighborIgnoreNonPeer (const Ip::Address &, icp_opcode)
 
static void dump_peers (StoreEntry *sentry, CachePeer *peers)
 
const char * neighborTypeStr (const CachePeer *p)
 
CachePeerwhichPeer (const Ip::Address &from)
 
peer_t neighborType (const CachePeer *p, const AnyP::Uri &url)
 
bool peerCanOpenMore (const CachePeer *p)
 Whether we can open new connections to the peer (e.g., despite max-conn) More...
 
bool peerHasConnAvailable (const CachePeer *p)
 Whether the peer has idle or standby connections that can be used now. More...
 
void peerConnClosed (CachePeer *p)
 Notifies peer of an associated connection closure. More...
 
int peerHTTPOkay (const CachePeer *p, PeerSelector *ps)
 
int neighborsCount (PeerSelector *ps)
 
CachePeergetFirstUpParent (PeerSelector *ps)
 
CachePeergetRoundRobinParent (PeerSelector *ps)
 
CachePeergetWeightedRoundRobinParent (PeerSelector *ps)
 
static void peerClearRRLoop (void *data)
 
void peerClearRRStart (void)
 
void peerClearRR ()
 
void peerAlive (CachePeer *p)
 
CachePeergetDefaultParent (PeerSelector *ps)
 
CachePeergetNextPeer (CachePeer *p)
 
CachePeergetFirstPeer (void)
 
static void neighborsRegisterWithCacheManager ()
 
void neighbors_init (void)
 
int neighborsUdpPing (HttpRequest *request, StoreEntry *entry, IRCB *callback, PeerSelector *ps, int *exprep, int *timeout)
 
lookup_t peerDigestLookup (CachePeer *p, PeerSelector *ps)
 
CachePeerneighborsDigestSelect (PeerSelector *ps)
 
void peerNoteDigestLookup (HttpRequest *request, CachePeer *p, lookup_t lookup)
 
static void neighborUpdateRtt (CachePeer *p, MemObject *mem)
 
static int ignoreMulticastReply (CachePeer *p, PeerSelector *ps)
 
void neighborsUdpAck (const cache_key *key, icp_common_t *header, const Ip::Address &from)
 
CachePeerpeerFindByName (const char *name)
 
CachePeerpeerFindByNameAndPort (const char *name, unsigned short port)
 
int neighborUp (const CachePeer *p)
 
time_t peerConnectTimeout (const CachePeer *peer)
 
time_t positiveTimeout (const time_t timeout)
 
static void peerDNSConfigure (const ipcache_addrs *ia, const Dns::LookupDetails &, void *data)
 
static void peerConnectFailedSilent (CachePeer *p)
 
void peerConnectFailed (CachePeer *p)
 
void peerConnectSucceded (CachePeer *p)
 
static bool peerProbeIsBusy (const CachePeer *p)
 whether new TCP probes are currently banned More...
 
static void peerProbeConnectDone (const Comm::ConnectionPointer &conn, Comm::Flag status, int, void *data)
 
static void peerCountHandleIcpReply (CachePeer *p, peer_t, AnyP::ProtocolType proto, void *, void *data)
 
static void neighborDumpPeers (StoreEntry *sentry)
 
static void neighborDumpNonPeers (StoreEntry *sentry)
 
void dump_peer_options (StoreEntry *sentry, CachePeer *p)
 
void neighborsHtcpReply (const cache_key *key, HtcpReplyData *htcp, const Ip::Address &from)
 
void neighborsHtcpClear (StoreEntry *e, const char *uri, HttpRequest *req, const HttpRequestMethod &method, htcp_clr_reason reason)
 

Variables

static IPH peerDNSConfigure
 
static CNCB peerProbeConnectDone
 
static IRCB peerCountHandleIcpReply
 
static OBJH neighborDumpPeers
 
static OBJH neighborDumpNonPeers
 
static unsigned short echo_port
 
static int NLateReplies = 0
 
static CachePeerfirst_ping = NULL
 
static CachePeernon_peers = NULL
 

Macro Definition Documentation

◆ MCAST_COUNT_RATE

#define MCAST_COUNT_RATE   900

Definition at line 49 of file neighbors.cc.

Function Documentation

◆ dump_peer_options()

void dump_peer_options ( StoreEntry sentry,
CachePeer p 
)

Definition at line 1493 of file neighbors.cc.

References p, PEER_TCP_MAGIC_COUNT, and storeAppendPrintf().

Referenced by dump_peer(), and dump_peers().

◆ dump_peers()

◆ getDefaultParent()

◆ getFirstPeer()

CachePeer* getFirstPeer ( void  )

Definition at line 504 of file neighbors.cc.

References Config, and SquidConfig::peers.

Referenced by statPeerSelect().

◆ getFirstUpParent()

◆ getNextPeer()

CachePeer* getNextPeer ( CachePeer p)

Definition at line 498 of file neighbors.cc.

References p.

Referenced by statPeerSelect().

◆ getRoundRobinParent()

◆ getWeightedRoundRobinParent()

◆ ignoreMulticastReply()

static int ignoreMulticastReply ( CachePeer p,
PeerSelector ps 
)
static

Definition at line 978 of file neighbors.cc.

References NULL, p, and peerHTTPOkay().

Referenced by neighborsHtcpReply(), and neighborsUdpAck().

◆ neighborAlive()

static void neighborAlive ( CachePeer p,
const MemObject ,
const icp_common_t header 
)
static

Definition at line 879 of file neighbors.cc.

References ICP_END, int, icp_common_t::opcode, p, peerAlive(), and icp_common_t::version.

Referenced by neighborsUdpAck().

◆ neighborAliveHtcp()

static void neighborAliveHtcp ( CachePeer p,
const MemObject ,
const HtcpReplyData htcp 
)
static

Definition at line 916 of file neighbors.cc.

References HtcpReplyData::hit, p, peerAlive(), and HtcpReplyData::version.

Referenced by neighborsHtcpReply().

◆ neighborCountIgnored()

static void neighborCountIgnored ( CachePeer p)
static

Definition at line 927 of file neighbors.cc.

References NLateReplies, NULL, and p.

Referenced by neighborsHtcpReply(), and neighborsUdpAck().

◆ neighborDumpNonPeers()

static void neighborDumpNonPeers ( StoreEntry sentry)
static

Definition at line 1487 of file neighbors.cc.

References dump_peers(), and non_peers.

◆ neighborDumpPeers()

static void neighborDumpPeers ( StoreEntry sentry)
static

Definition at line 1481 of file neighbors.cc.

References Config, dump_peers(), and SquidConfig::peers.

◆ neighborIgnoreNonPeer()

◆ neighborRemove()

static void neighborRemove ( CachePeer target)
static

Definition at line 510 of file neighbors.cc.

References Config, first_ping, SquidConfig::npeers, NULL, p, and SquidConfig::peers.

Referenced by neighbors_init(), and neighborsUdpAck().

◆ neighbors_init()

◆ neighborsCount()

int neighborsCount ( PeerSelector ps)

Definition at line 271 of file neighbors.cc.

References Config, debugs, NULL, p, SquidConfig::peers, and peerWouldBePinged().

Referenced by peerSelectIcpPing().

◆ neighborsDigestSelect()

◆ neighborsHtcpClear()

void neighborsHtcpClear ( StoreEntry e,
const char *  uri,
HttpRequest req,
const HttpRequestMethod method,
htcp_clr_reason  reason 
)

◆ neighborsHtcpReply()

◆ neighborsRegisterWithCacheManager()

static void neighborsRegisterWithCacheManager ( )
static

◆ neighborsUdpAck()

void neighborsUdpAck ( const cache_key key,
icp_common_t header,
const Ip::Address from 
)

◆ neighborsUdpPing()

◆ neighborType()

◆ neighborTypeStr()

const char* neighborTypeStr ( const CachePeer p)

◆ neighborUp()

◆ neighborUpdateRtt()

static void neighborUpdateRtt ( CachePeer p,
MemObject mem 
)
static

◆ peerAlive()

void peerAlive ( CachePeer p)

Perform all actions when a CachePeer is detected revived.

Definition at line 456 of file neighbors.cc.

References PeerPoolMgr::Checkpoint(), DBG_IMPORTANT, debugs, neighborTypeStr(), p, PEER_ALIVE, PEER_DEAD, peerClearRR(), and squid_curtime.

Referenced by neighborAlive(), neighborAliveHtcp(), and peerConnectSucceded().

◆ peerAllowedToUse()

◆ peerCanOpenMore()

bool peerCanOpenMore ( const CachePeer p)

Definition at line 221 of file neighbors.cc.

References debugs, p, and Squid_MaxFD.

Referenced by PeerPoolMgr::openNewConnection(), peerConnClosed(), and peerHTTPOkay().

◆ peerClearRR()

void peerClearRR ( void  )

Called whenever the round-robin counters need to be reset to a sane state. So far those times are:

  • On startup and reconfigure - to set the counters to sane initial settings.
  • When a CachePeer has revived from dead, to prevent the revived CachePeer being flooded with requests which it has 'missed' during the down period.

Definition at line 444 of file neighbors.cc.

References Config, NULL, p, and SquidConfig::peers.

Referenced by peerAlive(), and peerClearRRLoop().

◆ peerClearRRLoop()

static void peerClearRRLoop ( void *  data)
static

This gets called every 5 minutes to clear the round-robin counter. The exact timing is an arbitrary default, set on estimate timing of a large number of requests in a high-performance environment during the period. The larger the number of requests between cycled resets the more balanced the operations.

Parameters
dataunused.
Todo:
Make the reset timing a selectable parameter in squid.conf

Definition at line 415 of file neighbors.cc.

References data, eventAdd(), and peerClearRR().

Referenced by peerClearRRStart().

◆ peerClearRRStart()

void peerClearRRStart ( void  )

This gets called on startup and restart to kick off the CachePeer round-robin maintenance event. It ensures that no matter how many times its called no more than one event is scheduled.

Definition at line 427 of file neighbors.cc.

References NULL, and peerClearRRLoop().

Referenced by parse_peer().

◆ peerConnClosed()

void peerConnClosed ( CachePeer p)

Definition at line 245 of file neighbors.cc.

References PeerPoolMgr::Checkpoint(), p, and peerCanOpenMore().

Referenced by Comm::Connection::noteClosure().

◆ peerConnectFailed()

◆ peerConnectFailedSilent()

static void peerConnectFailedSilent ( CachePeer p)
static

Definition at line 1276 of file neighbors.cc.

References DBG_IMPORTANT, debugs, neighborTypeStr(), p, PEER_DEAD, and squid_curtime.

Referenced by peerConnectFailed(), and peerProbeConnectDone().

◆ peerConnectSucceded()

void peerConnectSucceded ( CachePeer p)

◆ peerConnectTimeout()

time_t peerConnectTimeout ( const CachePeer peer)

◆ peerCountHandleIcpReply()

static void peerCountHandleIcpReply ( CachePeer p,
peer_t  ,
AnyP::ProtocolType  proto,
void *  ,
void *  data 
)
static

◆ peerCountMcastPeersDone()

static void peerCountMcastPeersDone ( void *  data)
static

◆ peerCountMcastPeersSchedule()

static void peerCountMcastPeersSchedule ( CachePeer p,
time_t  when 
)
static

Definition at line 1380 of file neighbors.cc.

References eventAdd(), p, and peerCountMcastPeersStart().

Referenced by peerCountMcastPeersStart(), and peerDNSConfigure().

◆ peerCountMcastPeersStart()

◆ peerDigestLookup()

◆ peerDNSConfigure()

◆ peerFindByName()

CachePeer* peerFindByName ( const char *  name)

Definition at line 1121 of file neighbors.cc.

References Config, NULL, p, and SquidConfig::peers.

Referenced by netdbClosestParent(), parse_hostdomaintype(), parse_peer(), and parse_peer_access().

◆ peerFindByNameAndPort()

CachePeer* peerFindByNameAndPort ( const char *  name,
unsigned short  port 
)

Definition at line 1134 of file neighbors.cc.

References Config, NULL, p, SquidConfig::peers, and port.

◆ peerHasConnAvailable()

bool peerHasConnAvailable ( const CachePeer p)

Definition at line 230 of file neighbors.cc.

References debugs, and p.

Referenced by peerHTTPOkay().

◆ peerHTTPOkay()

◆ peerNoteDigestLookup()

void peerNoteDigestLookup ( HttpRequest request,
CachePeer p,
lookup_t  lookup 
)

Definition at line 865 of file neighbors.cc.

References debugs, lookup_t_str, p, and request().

Referenced by PeerSelector::handleIcpReply(), and neighborsDigestSelect().

◆ peerProbeConnect()

static void peerProbeConnect ( CachePeer p,
const bool  reprobeIfBusy = false 
)
static

◆ peerProbeConnectDone()

static void peerProbeConnectDone ( const Comm::ConnectionPointer conn,
Comm::Flag  status,
int  ,
void *  data 
)
static

◆ peerProbeIsBusy()

static bool peerProbeIsBusy ( const CachePeer p)
static

Definition at line 1316 of file neighbors.cc.

References debugs, p, and squid_curtime.

Referenced by peerProbeConnect().

◆ peerRefreshDNS()

static void peerRefreshDNS ( void *  data)
static

◆ peerWouldBePinged()

◆ positiveTimeout()

time_t positiveTimeout ( const time_t  timeout)
Returns
max(1, timeout)

Definition at line 1192 of file neighbors.cc.

References max().

Referenced by FwdState::connectingTimeout(), and PeerPoolMgr::handleOpenedConnection().

◆ whichPeer()

Variable Documentation

◆ echo_port

unsigned short echo_port
static

Definition at line 73 of file neighbors.cc.

Referenced by neighbors_init(), and neighborsUdpPing().

◆ first_ping

CachePeer* first_ping = NULL
static

◆ neighborDumpNonPeers

OBJH neighborDumpNonPeers
static

Definition at line 70 of file neighbors.cc.

Referenced by neighborsRegisterWithCacheManager().

◆ neighborDumpPeers

OBJH neighborDumpPeers
static

Definition at line 69 of file neighbors.cc.

Referenced by neighborsRegisterWithCacheManager().

◆ NLateReplies

int NLateReplies = 0
static

Definition at line 75 of file neighbors.cc.

Referenced by neighborCountIgnored().

◆ non_peers

CachePeer* non_peers = NULL
static

Definition at line 937 of file neighbors.cc.

Referenced by neighborDumpNonPeers(), and neighborIgnoreNonPeer().

◆ peerCountHandleIcpReply

IRCB peerCountHandleIcpReply
static

Definition at line 66 of file neighbors.cc.

Referenced by peerCountMcastPeersStart().

◆ peerDNSConfigure

IPH peerDNSConfigure
static

Definition at line 60 of file neighbors.cc.

Referenced by peerConnectSucceded(), and peerRefreshDNS().

◆ peerProbeConnectDone

CNCB peerProbeConnectDone
static

Definition at line 62 of file neighbors.cc.

Referenced by peerProbeConnect().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors