/*
- * $Id: neighbors.cc,v 1.211 1998/05/15 16:58:33 wessels Exp $
+ * $Id: neighbors.cc,v 1.212 1998/05/21 00:46:16 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
#define MCAST_COUNT_RATE 900
static int peerAllowedToUse(const peer *, request_t *);
-static int peerHTTPOkay(const peer *, request_t *);
static int peerWouldBePinged(const peer *, request_t *);
static void neighborRemove(peer *);
static peer *whichPeer(const struct sockaddr_in *from);
}
/* Return TRUE if it is okay to send an HTTP request to this peer. */
-static int
+int
peerHTTPOkay(const peer * p, request_t * request)
{
if (!peerAllowedToUse(p, request))
/*
- * $Id: net_db.cc,v 1.103 1998/05/20 21:06:23 wessels Exp $
+ * $Id: net_db.cc,v 1.104 1998/05/21 00:46:17 wessels Exp $
*
* DEBUG: section 37 Network Measurement Database
* AUTHOR: Duane Wessels
}
peer *
-netdbClosestParent(const char *host)
+netdbClosestParent(const request_t *request)
{
#if USE_ICMP
peer *p = NULL;
const ipcache_addrs *ia;
net_db_peer *h;
int i;
- n = netdbLookupHost(host);
+ n = netdbLookupHost(request->host);
if (NULL == n) {
/* try IP addr */
- ia = ipcache_gethostbyname(host, 0);
+ ia = ipcache_gethostbyname(request->host, 0);
if (NULL != ia)
n = netdbLookupAddr(ia->in_addrs[ia->cur]);
}
if (n->rtt > 0)
if (n->rtt < h->rtt)
break;
- if ((p = peerFindByName(h->peername)))
- return p;
+ p = peerFindByName(h->peername);
+ if (NULL == p) /* not found */
+ continue;
+ if (!peerHTTPOkay(p, request)) /* not allowed */
+ continue;
+ return p;
}
#endif
return NULL;
/*
- * $Id: peer_select.cc,v 1.58 1998/05/15 15:16:30 wessels Exp $
+ * $Id: peer_select.cc,v 1.59 1998/05/21 00:46:18 wessels Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
peerSelectCallback(psstate, p);
return;
#endif
- } else if ((p = netdbClosestParent(request->host))) {
+ } else if ((p = netdbClosestParent(request))) {
request->hier.alg = PEER_SA_NETDB;
code = CLOSEST_PARENT;
debug(44, 2) ("peerSelect: %s/%s\n", hier_strings[code], p->host);
extern char *neighborTypeStr(const peer * e);
extern void peerCheckConnectStart(peer *);
extern void dump_peer_options(StoreEntry *, peer *);
+extern int peerHTTPOkay(const peer *, request_t *);
extern void netdbInit(void);
extern void netdbHandlePingReply(const struct sockaddr_in *from, int hops, int rtt);
extern void netdbBinaryExchange(StoreEntry *);
extern EVH netdbExchangeStart;
extern void netdbExchangeUpdatePeer(struct in_addr, peer *, double, double);
-extern peer *netdbClosestParent(const char *host);
+extern peer *netdbClosestParent(const request_t *);
extern void cachemgrStart(int fd, request_t * request, StoreEntry * entry);
extern void cachemgrRegister(const char *, const char *, OBJH *, int);