From: wessels <> Date: Mon, 8 Jun 1998 23:29:14 +0000 (+0000) Subject: - Copied more robust TCP UP/DOWN patch from 1.1 code X-Git-Tag: SQUID_3_0_PRE1~3157 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98829f69cf123264b70b0be1c12925bc627e00af;p=thirdparty%2Fsquid.git - Copied more robust TCP UP/DOWN patch from 1.1 code - added 'unique_hostname' configuration option when people want to use the same visible hostname for multiple caches. --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index d38ad449ad..a8bbf0ade1 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.285 1998/06/03 20:34:41 wessels Exp $ + * $Id: cache_cf.cc,v 1.286 1998/06/08 17:29:14 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -278,7 +278,7 @@ configDoConfigure(void) if (Config.Port.http == NULL) fatal("No http_port specified!"); snprintf(ThisCache, sizeof(ThisCache), "%s:%d (%s)", - getMyHostname(), + uniqueHostname(), (int) Config.Port.http->i, full_appname_string); if (!Config.udpMaxHitObjsz || Config.udpMaxHitObjsz > SQUID_UDP_SO_SNDBUF) @@ -789,7 +789,7 @@ parse_peer(peer ** head) if (p->weight < 1) p->weight = 1; p->icp_version = ICP_VERSION_CURRENT; - p->tcp_up = 1; + p->tcp_up = PEER_TCP_MAGIC_COUNT; cbdataAdd(p, MEM_NONE); while (*head != NULL) head = &(*head)->next; diff --git a/src/cf.data.pre b/src/cf.data.pre index c19854261b..a37bf8a820 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1404,6 +1404,19 @@ DOC_START visible_hostname www-cache.foo.org DOC_END + +NAME: unique_hostname +TYPE: string +LOC: Config.uniqueHostname +DEFAULT: none +DOC_START + If you want to have multiple machines with the same + 'visible_hostname' then you must give each machine a different + 'unique_hostname' so that forwarding loops can be detected. + +unique_hostname www-cache1.foo.org +DOC_END + COMMENT_START OPTIONS FOR THE CACHE REGISTRATION SERVICE ----------------------------------------------------------------------------- diff --git a/src/client_db.cc b/src/client_db.cc index d4b5107f24..5737f179ba 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -1,6 +1,6 @@ /* - * $Id: client_db.cc,v 1.34 1998/05/30 19:43:04 rousskov Exp $ + * $Id: client_db.cc,v 1.35 1998/06/08 17:29:16 wessels Exp $ * * DEBUG: section 0 Client Database * AUTHOR: Duane Wessels @@ -43,6 +43,7 @@ clientdbAdd(struct in_addr addr) c->key = xstrdup(inet_ntoa(addr)); c->addr = addr; hash_join(client_table, (hash_link *) c); + Counter.client_http.clients++; return c; } diff --git a/src/defines.h b/src/defines.h index d44ad06e24..9267928bcd 100644 --- a/src/defines.h +++ b/src/defines.h @@ -235,3 +235,9 @@ */ #define INCOMING_HTTP_MAX 10 #define INCOMING_TOTAL_MAX (INCOMING_ICP_MAX+INCOMING_HTTP_MAX) + +/* + * This many TCP connections must FAIL before we mark the + * peer as DEAD + */ +#define PEER_TCP_MAGIC_COUNT 10 diff --git a/src/neighbors.cc b/src/neighbors.cc index cadf2f19d1..60ee124c42 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.221 1998/06/05 17:34:19 wessels Exp $ + * $Id: neighbors.cc,v 1.222 1998/06/08 17:29:17 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -545,7 +545,7 @@ neighborsUdpPing(request_t * request, else if (*exprep > 0) (*timeout) = 2 * (*timeout) / (*exprep); else - *timeout = 2000; /* 2 seconds */ + *timeout = 2000; /* 2 seconds */ return peers_pinged; } @@ -986,12 +986,12 @@ static void peerCheckConnectDone(int fd, int status, void *data) { peer *p = data; - p->tcp_up = status == COMM_OK ? 1 : 0; - if (p->tcp_up) { + if (status == COMM_OK) { + p->tcp_up = PEER_TCP_MAGIC_COUNT; debug(15, 0) ("TCP connection to %s/%d succeeded\n", p->host, p->http_port); } else { - eventAdd("peerCheckConnect", peerCheckConnect, p, 80.0, 1); + eventAdd("peerCheckConnect", peerCheckConnect, p, 60.0, 1); } comm_close(fd); return; @@ -1003,9 +1003,11 @@ peerCheckConnectStart(peer * p) if (!p->tcp_up) return; debug(15, 0) ("TCP connection to %s/%d failed\n", p->host, p->http_port); - p->tcp_up = 0; + p->tcp_up--; + if (p->tcp_up != (PEER_TCP_MAGIC_COUNT - 1)) + return; p->last_fail_time = squid_curtime; - eventAdd("peerCheckConnect", peerCheckConnect, p, 80.0, 1); + eventAdd("peerCheckConnect", peerCheckConnect, p, 30.0, 1); } static void diff --git a/src/protos.h b/src/protos.h index ed96fc715d..c1fc00424b 100644 --- a/src/protos.h +++ b/src/protos.h @@ -858,6 +858,7 @@ extern int storePendingNClients(const StoreEntry * e); extern const char *getMyHostname(void); +extern const char *uniqueHostname(void); extern void safeunlink(const char *path, int quiet); extern void death(int sig); extern void fatal(const char *message); diff --git a/src/stat.cc b/src/stat.cc index 478af4adbf..2ba9892cdd 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.257 1998/05/28 23:35:33 wessels Exp $ + * $Id: stat.cc,v 1.258 1998/06/08 17:29:19 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -471,6 +471,8 @@ info_get(StoreEntry * sentry) mkrfc1123(current_time.tv_sec)); storeAppendPrintf(sentry, "Connection information for %s:\n", appname); + storeAppendPrintf(sentry, "\tNumber of clients accessing cache:\t%u\n", + Counter.client_http.clients); storeAppendPrintf(sentry, "\tNumber of HTTP requests received:\t%u\n", Counter.client_http.requests); storeAppendPrintf(sentry, "\tNumber of ICP messages received:\t%u\n", diff --git a/src/structs.h b/src/structs.h index 66962257e6..b4ebcb3092 100644 --- a/src/structs.h +++ b/src/structs.h @@ -200,8 +200,8 @@ struct _SquidConfig { time_t pconn; time_t siteSelect; time_t deadPeer; - int icp_query; /* msec */ - int mcast_icp_query; /* msec */ + int icp_query; /* msec */ + int mcast_icp_query; /* msec */ } Timeout; size_t maxRequestSize; struct { @@ -260,6 +260,7 @@ struct _SquidConfig { char *pidFilename; char *mimeTablePathname; char *visibleHostname; + char *uniqueHostname; char *errHtmlText; struct { char *host; @@ -417,8 +418,8 @@ struct _dwrite_q { * Note: "str" points to memory in HttpHeaderEntry (for now) * so ETags should be used as tmp variables only (for now) */ struct _ETag { - const char *str; /* quoted-string */ - int weak; /* true if it is a weak validator */ + const char *str; /* quoted-string */ + int weak; /* true if it is a weak validator */ }; struct _fde { @@ -555,18 +556,18 @@ struct _HttpHdrContRange { /* some fields can hold either time or etag specs (e.g. If-Range) */ struct _TimeOrTag { - ETag tag; /* entity tag */ + ETag tag; /* entity tag */ time_t time; - int valid; /* true if struct is usable */ + int valid; /* true if struct is usable */ }; /* data for iterating thru range specs */ -struct _HttpHdrRangeIter { +struct _HttpHdrRangeIter { HttpHdrRangePos pos; - const HttpHdrRangeSpec *spec; /* current spec at pos */ - size_t debt_size; /* bytes left to send from the current spec */ - size_t prefix_size; /* the size of the incoming HTTP msg prefix */ - String boundary; /* boundary for multipart responses */ + const HttpHdrRangeSpec *spec; /* current spec at pos */ + size_t debt_size; /* bytes left to send from the current spec */ + size_t prefix_size; /* the size of the incoming HTTP msg prefix */ + String boundary; /* boundary for multipart responses */ }; /* constant attributes of http header fields */ @@ -661,7 +662,7 @@ struct _icp_ping_data { int n_sent; int n_recv; int n_replies_expected; - int timeout; /* msec */ + int timeout; /* msec */ int timedout; int w_rtt; int p_rtt; @@ -717,8 +718,8 @@ struct _clientHttpRequest { off_t offset; size_t size; } out; - HttpHdrRangeIter range_iter;/* data for iterating thru range specs */ - size_t req_sz; /* raw request size on input, not current request size */ + HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ + size_t req_sz; /* raw request size on input, not current request size */ StoreEntry *entry; StoreEntry *old_entry; log_type log_type; @@ -1210,6 +1211,7 @@ struct _StatHist { */ struct _StatCounters { struct { + int clients; int requests; int hits; int errors; diff --git a/src/tools.cc b/src/tools.cc index 593441f41a..c2437397ff 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.157 1998/06/03 20:48:21 rousskov Exp $ + * $Id: tools.cc,v 1.158 1998/06/08 17:29:21 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -524,6 +524,12 @@ getMyHostname(void) return host; } +const char * +uniqueHostname(void) +{ + return Config.uniqueHostname ? Config.uniqueHostname : getMyHostname(); +} + void safeunlink(const char *s, int quiet) {