]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed the forwarding / peer detection code so that a peer which is found
authoradrian <>
Wed, 15 Nov 2000 19:53:49 +0000 (19:53 +0000)
committeradrian <>
Wed, 15 Nov 2000 19:53:49 +0000 (19:53 +0000)
to be us is ignored rather than committing suicide.

Submitted by: Brian Degenhardt <bmd@mp3.com>

CONTRIBUTORS
ChangeLog
src/cache_cf.cc
src/tools.cc

index c56ff77e53f257c81ea4bb3777730caf30d4ff90..cc65dd0473473899d5064c2d7b300fc77aa09a83 100644 (file)
@@ -72,6 +72,7 @@ and ideas to make this software available.
        John Dilley <jad@hpl.hp.com>
        Adrian Chadd <adrian@creative.net.au>
        Robert Collins <robert.collins@itdomain.com.au>
+       Brian Degenhardt <bmd@mp3.com>
 
 Development of this caching software is funded by the National Science
 Foundation (grants NCR-9616602 and NCR-9521745).  Paid staff members on
index 6d710cf4c8a6e89c8aae8929c6c4679fbe20f82d..51997bef18ceecbe934fdd07d7195e4cc5dc48fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
 
+Changes to squid-2.5
+       - Fixed forwarding/peer loop detection code (Brian Degenhardt) -
+         now a peer is ignored if it turns out to be us, rather than
+         committing suicide
+
 Changes to Squid-2.4.DEVEL4 ():
 
        - Added --enable-auth-modules=... configure option
index 46656c09284edec3c0cca568ba335577348983d5..59d335421f71be02c4a5da99f492e324cff2d6ec 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.354 2000/09/17 23:41:55 hno Exp $
+ * $Id: cache_cf.cc,v 1.355 2000/11/15 12:53:50 adrian Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -1029,7 +1029,7 @@ parse_peer(peer ** head)
     peer *p;
     int i;
     sockaddr_in_list *s;
-    const char *me = null_string;      /* XXX */
+    const char *me = getMyHostname();
     p = memAllocate(MEM_PEER);
     p->http_port = CACHE_HTTP_PORT;
     p->icp.port = CACHE_ICP_PORT;
@@ -1049,9 +1049,11 @@ parse_peer(peer ** head)
        for (s = Config.Sockaddr.http; s; s = s->next) {
            if (p->http_port != ntohs(s->s.sin_port))
                continue;
-           debug(15, 0) ("parse_peer: Peer looks like myself: %s %s/%d/%d\n",
-               p->type, p->host, p->http_port, p->icp.port);
-           self_destruct();
+            debug(15, 1) ("parse_peer: Peer looks like myself: Ignoring %s %s/%d/%d\n",
+                 neighborTypeStr(p), p->host, p->http_port, p->icp.port);
+            xfree( p->host );
+            memFree( p, MEM_PEER );
+            return;
        }
     }
     while ((token = strtok(NULL, w_space))) {
index 0b47ecb1e844daa5bfc28c33265e70343c243770..9675efd5f7acb560ec8d4944c782d44deb679e4f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.197 2000/10/17 08:06:05 adrian Exp $
+ * $Id: tools.cc,v 1.198 2000/11/15 12:53:50 adrian Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -449,9 +449,11 @@ getMyHostname(void)
                inet_ntoa(Config.Sockaddr.http->s.sin_addr),
                host);
            present = 1;
-           return host;
+            if( strchr( host, '.' ) )
+                return host;
+
        }
-       debug(50, 1) ("WARNING: failed to resolve %s to a hostname\n",
+        debug(50, 1) ("WARNING: failed to resolve %s to a fully qualified hostname\n",
            inet_ntoa(Config.Sockaddr.http->s.sin_addr));
     }
     /*
@@ -468,7 +470,8 @@ getMyHostname(void)
        /* use the official name from DNS lookup */
        xstrncpy(host, h->h_name, SQUIDHOSTNAMELEN);
        present = 1;
-       return host;
+        if( strchr( host, '.' ) )
+            return host;
     }
     fatal("Could not determine fully qualified hostname.  Please set 'visible_hostname'\n");
     return NULL;               /* keep compiler happy */