From: adrian <> Date: Wed, 15 Nov 2000 19:53:49 +0000 (+0000) Subject: Fixed the forwarding / peer detection code so that a peer which is found X-Git-Tag: SQUID_3_0_PRE1~1766 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e396d395941887bfb30160a9a09ba2b5ce400d37;p=thirdparty%2Fsquid.git Fixed the forwarding / peer detection code so that a peer which is found to be us is ignored rather than committing suicide. Submitted by: Brian Degenhardt --- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c56ff77e53..cc65dd0473 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -72,6 +72,7 @@ and ideas to make this software available. John Dilley Adrian Chadd Robert Collins + Brian Degenhardt Development of this caching software is funded by the National Science Foundation (grants NCR-9616602 and NCR-9521745). Paid staff members on diff --git a/ChangeLog b/ChangeLog index 6d710cf4c8..51997bef18 100644 --- 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 diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 46656c0928..59d335421f 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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))) { diff --git a/src/tools.cc b/src/tools.cc index 0b47ecb1e8..9675efd5f7 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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 */