/*
- * $Id: cache_cf.cc,v 1.257 1998/03/07 23:43:01 rousskov Exp $
+ * $Id: cache_cf.cc,v 1.258 1998/03/16 21:45:00 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
neighborTypeStr(p),
p->http_port,
p->icp_port);
- if (EBIT_TEST(p->options, NEIGHBOR_PROXY_ONLY))
- storeAppendPrintf(entry, " proxy-only");
- if (EBIT_TEST(p->options, NEIGHBOR_NO_QUERY))
- storeAppendPrintf(entry, " no-query");
- if (EBIT_TEST(p->options, NEIGHBOR_DEFAULT_PARENT))
- storeAppendPrintf(entry, " default");
- if (EBIT_TEST(p->options, NEIGHBOR_ROUNDROBIN))
- storeAppendPrintf(entry, " round-robin");
- if (EBIT_TEST(p->options, NEIGHBOR_MCAST_RESPONDER))
- storeAppendPrintf(entry, " multicast-responder");
- if (EBIT_TEST(p->options, NEIGHBOR_CLOSEST_ONLY))
- storeAppendPrintf(entry, " closest-only");
- if (p->mcast.ttl > 0)
- storeAppendPrintf(entry, " ttl=%d", p->mcast.ttl);
- storeAppendPrintf(entry, "\n");
+ dump_peer_options(entry, p);
p = p->next;
}
}
}
while ((token = strtok(NULL, w_space))) {
if (!strcasecmp(token, "proxy-only")) {
- p->options |= NEIGHBOR_PROXY_ONLY;
+ EBIT_SET(p->options, NEIGHBOR_PROXY_ONLY);
} else if (!strcasecmp(token, "no-query")) {
- p->options |= NEIGHBOR_NO_QUERY;
+ EBIT_SET(p->options, NEIGHBOR_NO_QUERY);
} else if (!strcasecmp(token, "multicast-responder")) {
- p->options |= NEIGHBOR_MCAST_RESPONDER;
+ EBIT_SET(p->options, NEIGHBOR_MCAST_RESPONDER);
} else if (!strncasecmp(token, "weight=", 7)) {
p->weight = atoi(token + 7);
} else if (!strncasecmp(token, "closest-only", 12)) {
- p->options |= NEIGHBOR_CLOSEST_ONLY;
+ EBIT_SET(p->options, NEIGHBOR_CLOSEST_ONLY);
} else if (!strncasecmp(token, "ttl=", 4)) {
p->mcast.ttl = atoi(token + 4);
if (p->mcast.ttl < 0)
if (p->mcast.ttl > 128)
p->mcast.ttl = 128;
} else if (!strncasecmp(token, "default", 7)) {
- p->options |= NEIGHBOR_DEFAULT_PARENT;
+ EBIT_SET(p->options, NEIGHBOR_DEFAULT_PARENT);
} else if (!strncasecmp(token, "round-robin", 11)) {
- p->options |= NEIGHBOR_ROUNDROBIN;
+ EBIT_SET(p->options, NEIGHBOR_ROUNDROBIN);
} else {
debug(3, 0) ("parse_peer: token='%s'\n", token);
self_destruct();
/*
- * $Id: http.cc,v 1.254 1998/03/16 20:11:51 wessels Exp $
+ * $Id: http.cc,v 1.255 1998/03/16 21:45:01 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
Counter.server.all.requests++;
Counter.server.http.requests++;
if (e) {
- if (e->options & NEIGHBOR_PROXY_ONLY)
+ if (EBIT_TEST(e->options, NEIGHBOR_PROXY_ONLY))
storeReleaseRequest(entry);
if ((fd = pconnPop(e->host, e->http_port)) >= 0) {
debug(11, 3) ("httpStart: reusing pconn FD %d\n", fd);
/*
- * $Id: neighbors.cc,v 1.179 1998/03/06 22:53:07 wessels Exp $
+ * $Id: neighbors.cc,v 1.180 1998/03/16 21:45:02 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
{
if (!peerAllowedToUse(p, request))
return 0;
- if (p->options & NEIGHBOR_NO_QUERY)
+ if (EBIT_TEST(p->options, NEIGHBOR_NO_QUERY))
return 0;
- if (p->options & NEIGHBOR_MCAST_RESPONDER)
+ if (EBIT_TEST(p->options, NEIGHBOR_MCAST_RESPONDER))
return 0;
/* the case below seems strange, but can happen if the
* URL host is on the other side of a firewall */
return NULL; /* oops, found second parent */
p = q;
}
+ if (p != NULL && !EBIT_TEST(p->options, NEIGHBOR_NO_QUERY))
+ return NULL;
debug(15, 3) ("getSingleParent: returning %s\n", p ? p->host : "NULL");
return p;
}
#if ALLOW_SOURCE_PING
/* only do source_ping if we have neighbors */
if (Config.npeers) {
- const ipcache_addrs *ia = NULL;
- struct sockaddr_in to_addr;
- char *host = request->host;
+ const ipcache_addrs *ia = NULL;
+ struct sockaddr_in to_addr;
+ char *host = request->host;
if (!Config.onoff.source_ping) {
debug(15, 6) ("neighborsUdpPing: Source Ping is disabled.\n");
} else if ((ia = ipcache_gethostbyname(host, 0))) {
dump_peers(sentry, non_peers);
}
+void
+dump_peer_options(StoreEntry * sentry, peer * p)
+{
+ if (EBIT_TEST(p->options, NEIGHBOR_PROXY_ONLY))
+ storeAppendPrintf(sentry, " proxy-only");
+ if (EBIT_TEST(p->options, NEIGHBOR_NO_QUERY))
+ storeAppendPrintf(sentry, " no-query");
+ if (EBIT_TEST(p->options, NEIGHBOR_DEFAULT_PARENT))
+ storeAppendPrintf(sentry, " default");
+ if (EBIT_TEST(p->options, NEIGHBOR_ROUNDROBIN))
+ storeAppendPrintf(sentry, " round-robin");
+ if (EBIT_TEST(p->options, NEIGHBOR_MCAST_RESPONDER))
+ storeAppendPrintf(sentry, " multicast-responder");
+ if (EBIT_TEST(p->options, NEIGHBOR_CLOSEST_ONLY))
+ storeAppendPrintf(sentry, " closest-only");
+ if (p->mcast.ttl > 0)
+ storeAppendPrintf(sentry, " ttl=%d", p->mcast.ttl);
+ storeAppendPrintf(sentry, "\n");
+}
+
static void
dump_peers(StoreEntry * sentry, peer * peers)
{
e->host,
e->http_port,
e->icp_port);
+ storeAppendPrintf(sentry, "Flags :");
+ dump_peer_options(sentry, e);
for (i = 0; i < e->n_addresses; i++) {
storeAppendPrintf(sentry, "Address[%d] : %s\n", i,
inet_ntoa(e->addresses[i]));
/*
- * $Id: peer_select.cc,v 1.40 1998/03/06 22:53:06 wessels Exp $
+ * $Id: peer_select.cc,v 1.41 1998/03/16 21:45:03 wessels Exp $
*
* DEBUG: section 44 Peer Selection Algorithm
* AUTHOR: Duane Wessels
assert(direct != DIRECT_YES);
if (!EBIT_TEST(entry->flag, HIERARCHICAL) && direct != DIRECT_NO)
return 0;
- if (Config.onoff.single_parent_bypass)
-#if ALLOW_SOURCE_PING
- if (!Config.onoff.source_ping)
-#endif
- if (getSingleParent(request))
- return 0;
if (EBIT_TEST(entry->flag, KEY_PRIVATE) && !neighbors_do_private_keys)
if (direct != DIRECT_NO)
return 0;
*code = DEFAULT_PARENT;
return p;
}
- if ((p = getSingleParent(request))) {
- *code = SINGLE_PARENT;
- return p;
- }
if ((p = getRoundRobinParent(request))) {
*code = ROUNDROBIN_PARENT;
return p;
peerSelectCallback(psstate, NULL);
return;
}
- if (peerSelectIcpPing(request, direct, entry)) {
+ psstate->single_parent = getSingleParent(request);
+ debug(0, 0) ("psstate->single_parent = %p\n", psstate->single_parent);
+ if (psstate->single_parent != NULL) {
+ debug(44, 3) ("peerSelect: found single parent, skipping ICP query\n");
+ } else if (peerSelectIcpPing(request, direct, entry)) {
assert(entry->ping_status == PING_NONE);
debug(44, 3) ("peerSelect: Doing ICP pings\n");
psstate->icp.n_sent = neighborsUdpPing(request,
debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host);
hierarchyNote(&request->hier, code, &psstate->icp, p->host);
peerSelectCallback(psstate, p);
+ } else if ((p = psstate->single_parent)) {
+ code = SINGLE_PARENT;
+ debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host);
+ hierarchyNote(&request->hier, code, &psstate->icp, p->host);
+ peerSelectCallback(psstate, p);
} else if (direct != DIRECT_NO) {
code = DIRECT;
debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], request->host);
/* Http Range Header Field */
extern HttpHdrRange *httpHdrRangeParseCreate(const char *range_spec);
/* returns true if ranges are valid; inits HttpHdrRange */
-extern int httpHdrRangeParseInit(HttpHdrRange *range, const char *range_spec);
-extern void httpHdrRangeDestroy(HttpHdrRange *range);
+extern int httpHdrRangeParseInit(HttpHdrRange * range, const char *range_spec);
+extern void httpHdrRangeDestroy(HttpHdrRange * range);
extern HttpHdrRange *httpHdrRangeDup(const HttpHdrRange * range);
extern void httpHdrRangePackInto(const HttpHdrRange * range, Packer * p);
/* iterate through specs */
-extern int httpHdrRangeGetSpec(const HttpHdrRange *range, HttpHdrRangeSpec *spec, int *pos);
+extern int httpHdrRangeGetSpec(const HttpHdrRange * range, HttpHdrRangeSpec * spec, int *pos);
/* Http Content Range Header Field */
extern HttpHdrContRange *httpHdrContRangeParseCreate(const char *crange_spec);
/* returns true if range is valid; inits HttpHdrContRange */
-extern int httpHdrContRangeParseInit(HttpHdrContRange *crange, const char *crange_spec);
-extern void httpHdrContRangeDestroy(HttpHdrContRange *crange);
+extern int httpHdrContRangeParseInit(HttpHdrContRange * crange, const char *crange_spec);
+extern void httpHdrContRangeDestroy(HttpHdrContRange * crange);
extern HttpHdrContRange *httpHdrContRangeDup(const HttpHdrContRange * crange);
extern void httpHdrContRangePackInto(const HttpHdrContRange * crange, Packer * p);
/* Http Header Tools */
extern HttpHeaderFieldInfo *httpHeaderBuildFieldsInfo(const HttpHeaderFieldAttrs * attrs, int count);
-extern void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo *info, int count);
-extern int httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo* attrs, int end, int mask);
+extern void httpHeaderDestroyFieldsInfo(HttpHeaderFieldInfo * info, int count);
+extern int httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * attrs, int end, int mask);
extern int httpHeaderCalcMask(const int *enums, int count);
extern int strListGetItem(const char *str, char del, const char **item, int *ilen, const char **pos);
extern const char *getStringPrefix(const char *str);
extern void httpHeaderClean(HttpHeader * hdr);
extern void httpHeaderDestroy(HttpHeader * hdr);
/* clone */
-void httpHeaderCopy(HttpHeader *dest, const HttpHeader *src);
+void httpHeaderCopy(HttpHeader * dest, const HttpHeader * src);
/* parse/pack */
extern int httpHeaderParse(HttpHeader * hdr, const char *header_start, const char *header_end);
extern void httpHeaderPackInto(const HttpHeader * hdr, Packer * p);
extern void peerDestroy(peer * e);
extern char *neighborTypeStr(const peer * e);
extern void peerCheckConnectStart(peer *);
+extern void dump_peer_options(StoreEntry *, peer *);
extern void netdbInit(void);
extern void memCleanModule();
extern void memConfigure();
extern void *memAllocate(mem_type);
-extern void *memAllocBuf(size_t net_size, size_t *gross_size);
+extern void *memAllocBuf(size_t net_size, size_t * gross_size);
extern void memFree(mem_type, void *);
extern void memFreeBuf(size_t size, void *);
extern void memFree4K(void *);
extern void dumpMallocStats(void);
extern void pumpInit(int fd, request_t * r, char *uri);
-extern void pumpStart(int, StoreEntry *, request_t *, CWCB *callback, void *);
+extern void pumpStart(int, StoreEntry *, request_t *, CWCB * callback, void *);
extern int pumpMethod(method_t method);
extern int pumpRestart(request_t *);
#define strSet(s,ptr,ch) (s).buf[ptr-(s).buf] = (ch)
#define strCut(s,pos) (s).buf[pos] = '\0'
/* #define strCat(s,str) stringAppend(&(s), (str), strlen(str)+1) */
-extern void stringInit(String *s, const char *str);
-extern void stringLimitInit(String *s, const char *str, int len);
-extern String stringDup(const String *s);
-extern void stringClean(String *s);
-extern void stringReset(String *s, const char *str);
-extern void stringAppend(String *s, const char *buf, int len);
+extern void stringInit(String * s, const char *str);
+extern void stringLimitInit(String * s, const char *str, int len);
+extern String stringDup(const String * s);
+extern void stringClean(String * s);
+extern void stringReset(String * s, const char *str);
+extern void stringAppend(String * s, const char *buf, int len);
/* extern void stringAppendf(String *s, const char *fmt, ...); */
/*
struct _String {
/* never reference these directly! */
- unsigned short int size; /* buffer size; 64K limit */
- unsigned short int len; /* current length */
+ unsigned short int size; /* buffer size; 64K limit */
+ unsigned short int len; /* current length */
char *buf;
};
/* http header extention field */
struct _HttpHdrExtField {
- String name; /* field-name from HTTP/1.1 (no column after name) */
- String value; /* field-value from HTTP/1.1 */
+ String name; /* field-name from HTTP/1.1 (no column after name) */
+ String value; /* field-value from HTTP/1.1 */
};
/* http cache control header field */
/* http content-range header field */
struct _HttpHdrContRange {
HttpHdrRangeSpec spec;
- size_t elength; /* entity length, not content length */
+ size_t elength; /* entity length, not content length */
};
void *callback_data;
peer *first_parent_miss;
peer *closest_parent_miss;
+ peer *single_parent;
icp_ping_data icp;
aclCheck_t *acl_checklist;
};
char login[MAX_LOGIN_SZ];
char host[SQUIDHOSTNAMELEN + 1];
u_short port;
-#if 0 /* trying new interface */
+#if 0 /* trying new interface */
char urlpath[MAX_URL];
#else
String urlpath;