]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
- Copied more robust TCP UP/DOWN patch from 1.1 code
authorwessels <>
Mon, 8 Jun 1998 23:29:14 +0000 (23:29 +0000)
committerwessels <>
Mon, 8 Jun 1998 23:29:14 +0000 (23:29 +0000)
- added 'unique_hostname' configuration option when people want to use
  the same visible hostname for multiple caches.

src/cache_cf.cc
src/cf.data.pre
src/client_db.cc
src/defines.h
src/neighbors.cc
src/protos.h
src/stat.cc
src/structs.h
src/tools.cc

index d38ad449ad8dc65a3c4f5dd48d9561a1f78f9afa..a8bbf0ade159557bb5ad5322dea0dfb5888ad3dc 100644 (file)
@@ -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;
index c19854261bb5e590b83e30dfbe0d08a3c924062d..a37bf8a820129225c4845d3f1694feaf63b79fab 100644 (file)
@@ -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
  -----------------------------------------------------------------------------
index d4b5107f24060497494d41e38b3a6c7e5c754abc..5737f179baf0652d344d92b119c6182129863b8f 100644 (file)
@@ -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;
 }
 
index d44ad06e246bef74bd0d162f4c437d2270cfdd0e..9267928bcdf09d2cc5e700387ae5ec1dcb4142ff 100644 (file)
  */
 #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
index cadf2f19d1f2add2ba86942ac0ffd2760e7b98a2..60ee124c4254a13d627067e3c1219b43b09d83bb 100644 (file)
@@ -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
index ed96fc715d301da58a7d28f8f4ad9c1734b35f94..c1fc00424bc8c792600e1c5cdec77c845b12ef97 100644 (file)
@@ -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);
index 478af4adbfd7f4cea88d4827aff7a2f86a33c332..2ba9892cdd279db9282d61d3366ceffc329deb6e 100644 (file)
@@ -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",
index 66962257e63f146b99bdd56fdb602539900853b4..b4ebcb3092bc448c99614cbba7f0be9ee8d8f82b 100644 (file)
@@ -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;
index 593441f41ae97da8c5ddc1dc6e5051b1160726bf..c2437397ffe46f8b0b1c5279fb2d36abfae586a5 100644 (file)
@@ -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)
 {