]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Mark Nottingham <mnot@pobox.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 8 May 2009 11:22:30 +0000 (23:22 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 8 May 2009 11:22:30 +0000 (23:22 +1200)
Make PEER_TCP_MAGIC_COUNT configurable

Squid will consider a peer dead when it has ten connect failures; this is
hardcoded in as PEER_TCP_MAGIC_COUNT.

The attached patch makes it a per-peer configuration option, defaulting to
PEER_TCP_MAGIC_COUNT.

doc/release-notes/release-3.1.sgml
src/cache_cf.cc
src/cf.data.pre
src/neighbors.cc
src/structs.h

index 7508a7b6c27701f6dc0a438c366f8cdb6c9f8a51..2db731f905392097fb9057fd7232236d8b44244c 100644 (file)
@@ -835,7 +835,7 @@ NOCOMMENT_START
        <tag>cache_mem</tag>
        <p>Default size increased to 256MB.
 
-       <tag>cache_peer htcp-no-clr htcp-no-purge-clr htcp-only-clr htcp-forward-clr connection-auth[=on|off|auto]</tag>
+       <tag>cache_peer htcp-no-clr htcp-no-purge-clr htcp-only-clr htcp-forward-clr connection-auth[=on|off|auto] connect-fail-limit=N</tag>
        <p>New Options.
        <verb>
        use 'htcp-no-clr' to send HTCP to the neighbor but without
@@ -857,6 +857,10 @@ NOCOMMENT_START
        and any such challenges received from there should be
        ignored. Default is 'auto' to automatically determine the
        status of the peer.
+
+       use 'connect-fail-limit=nn' to specify how many times
+       connecting to a peer must fail before it is marked as
+       down. Default is 10.
        </verb>
 
        <tag>cache_store_log</tag>
index debb829dcd81b4055a1a882bbe3b1784322c5cc6..0d9c54226b976c1f72b055680cc6789b2c9db9c6 100644 (file)
@@ -1777,8 +1777,9 @@ parse_peer(peer ** head)
             rfc1738_unescape(p->login);
         } else if (!strncasecmp(token, "connect-timeout=", 16)) {
             p->connect_timeout = xatoi(token + 16);
+        } else if (!strncasecmp(token, "connect-fail-limit=", 19)) {
+            p->connect_fail_limit = xatoi(token + 19);
 #if USE_CACHE_DIGESTS
-
         } else if (!strncasecmp(token, "digest-url=", 11)) {
             p->digest_url = xstrdup(token + 11);
 #endif
@@ -1861,6 +1862,9 @@ parse_peer(peer ** head)
     if (p->weight < 1)
         p->weight = 1;
 
+    if (p->connect_fail_limit < 1)
+        p->connect_fail_limit = 1;
+
     p->icp.version = ICP_VERSION_CURRENT;
 
     p->test_fd = -1;
index f60b9023111b0fbeeb95763111e2fe4a380b9b66..382f84dfeee6c2ddefdba93ccd83efef75fd04ba 100644 (file)
@@ -1602,6 +1602,7 @@ DOC_START
                     no-delay
                     login=user:password | PASS | *:password
                     connect-timeout=nn
+                    connect-fail-limit=nn
                     digest-url=url
                     allow-miss
                     max-conn=n
@@ -1727,6 +1728,10 @@ DOC_START
                     specific connect timeout (also see the
                     peer_connect_timeout directive)
 
+                    use 'connect-fail-limit=nn' to specify how many times
+                    connecting to a peer must fail before it is marked as
+                    down. Default is 10.
+
                     use 'digest-url=url' to tell Squid to fetch the cache
                     digest (if digests are enabled) for this host from
                     the specified URL rather than the Squid default
index b40c53f840274f8dfab6bea07c65954ff8ab6a53..3a190fbd9bfbfaf57db553a0331a2c190b2242b0 100644 (file)
@@ -1255,7 +1255,7 @@ peerDNSConfigure(const ipcache_addrs * ia, void *data)
         return;
     }
 
-    p->tcp_up = PEER_TCP_MAGIC_COUNT;
+    p->tcp_up = p->connect_fail_limit;
 
     for (j = 0; j < (int) ia->count && j < PEER_MAX_ADDRESSES; j++) {
         p->addresses[j] = ia->in_addrs[j];
@@ -1330,12 +1330,12 @@ peerConnectSucceded(peer * p)
 {
     if (!p->tcp_up) {
         debugs(15, 2, "TCP connection to " << p->host << "/" << p->http_port << " succeded");
-        p->tcp_up = PEER_TCP_MAGIC_COUNT; // NP: so peerAlive(p) works properly.
+        p->tcp_up = p->connect_fail_limit; // NP: so peerAlive(p) works properly.
         peerAlive(p);
         if (!p->n_addresses)
             ipcache_nbgethostbyname(p->host, peerDNSConfigure, p);
     } else
-        p->tcp_up = PEER_TCP_MAGIC_COUNT;
+        p->tcp_up = p->connect_fail_limit;
 }
 
 /// called by Comm when test_fd is closed while connect is in progress
@@ -1611,6 +1611,9 @@ dump_peer_options(StoreEntry * sentry, peer * p)
     if (p->connect_timeout > 0)
         storeAppendPrintf(sentry, " connect-timeout=%d", (int) p->connect_timeout);
 
+    if (p->connect_fail_limit != PEER_TCP_MAGIC_COUNT)
+        storeAppendPrintf(sentry, " connect-fail-limit=%d", p->connect_fail_limit);
+
 #if USE_CACHE_DIGESTS
 
     if (p->digest_url)
index f28c9cca396e07c9142041591cb39f495c74901b..e679e8f72ebc1a4a99f3882790017fd124dd3a7a 100644 (file)
@@ -929,6 +929,7 @@ struct peer {
 
     char *login;               /* Proxy authorization */
     time_t connect_timeout;
+    int connect_fail_limit;
     int max_conn;
     char *domain;              /* Forced domain */
 #if USE_SSL