From: hno <> Date: Mon, 18 Oct 2004 18:20:09 +0000 (+0000) Subject: Bug #1058: balance_on_multiple_ip directive to make it possible to X-Git-Tag: SQUID_3_0_PRE4~1014 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a12a049a308bee40270d36d39f306b60eea14179;p=thirdparty%2Fsquid.git Bug #1058: balance_on_multiple_ip directive to make it possible to turn of the automatic round-robin on sites with multiple IP addresses optimized ipcache usage on reload when using the internal TTL aware dns client. --- diff --git a/src/cf.data.pre b/src/cf.data.pre index 5fbea85db1..4d429dfb3a 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.359 2004/10/10 02:49:04 hno Exp $ +# $Id: cf.data.pre,v 1.360 2004/10/18 12:20:09 hno Exp $ # # # SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -4250,6 +4250,19 @@ DOC_START disable persistent connections with clients and/or servers. DOC_END +NAME: balance_on_multiple_ip +TYPE: onoff +LOC: Config.onoff.balance_on_multiple_ip +DEFAULT: on +DOC_START + Some load balancing servers based on round robin DNS have been + found not to preserve user session state across requests + to different IP addresses. + + By default Squid rotates IP's per request. By disabling + this directive only connection failure triggers rotation. +DOC_END + NAME: pipeline_prefetch TYPE: onoff LOC: Config.onoff.pipeline_prefetch diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 5c9fe54fcb..2ce6e16ef7 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.73 2004/10/14 23:32:45 hno Exp $ + * $Id: client_side_reply.cc,v 1.74 2004/10/18 12:20:09 hno Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1496,17 +1496,39 @@ clientReplyContext::identifyFoundObject(StoreEntry *newEntry) } e = http->storeEntry(); - /* Release negatively cached IP-cache entries on reload */ + /* Release IP-cache entries on reload */ + + if (r->flags.nocache) { + +#if USE_DNSSERVERS - if (r->flags.nocache) ipcacheInvalidate(r->host); +#else + + ipcacheInvalidateNegative(r->host); + +#endif /* USE_DNSSERVERS */ + + } + #if HTTP_VIOLATIONS - else if (r->flags.nocache_hack) + else if (r->flags.nocache_hack) { + +#if USE_DNSSERVERS + ipcacheInvalidate(r->host); -#endif +#else + + ipcacheInvalidateNegative(r->host); + +#endif /* USE_DNSSERVERS */ + + } + +#endif /* HTTP_VIOLATIONS */ #if USE_CACHE_DIGESTS lookup_type = http->storeEntry() ? "HIT" : "MISS"; diff --git a/src/comm.cc b/src/comm.cc index 7e9e5b41eb..0d6666a62d 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.395 2004/08/30 05:12:31 robertc Exp $ + * $Id: comm.cc,v 1.396 2004/10/18 12:20:09 hno Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1231,9 +1231,14 @@ commConnectDnsHandle(const ipcache_addrs * ia, void *data) assert(ia->cur < ia->count); cs->in_addr = ia->in_addrs[ia->cur]; - ipcacheCycleAddr(cs->host, NULL); + + if (Config.onoff.balance_on_multiple_ip) + ipcacheCycleAddr(cs->host, NULL); + cs->addrcount = ia->count; + cs->connstart = squid_curtime; + cs->connect(); } diff --git a/src/ipcache.cc b/src/ipcache.cc index 61166ff259..c6635f6f7d 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.245 2004/10/15 21:12:47 hno Exp $ + * $Id: ipcache.cc,v 1.246 2004/10/18 12:20:10 hno Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -129,6 +129,7 @@ ipcache_testname(void) static void ipcacheRelease(ipcache_entry * i) { + debug(14, 3) ("ipcacheRelease: Releasing entry for '%s'\n", (const char *) i->hash.key); hash_remove_link(ip_table, (hash_link *) i); dlinkDelete(&i->lru, &lru_list); ipcacheFreeEntry(i); @@ -394,7 +395,7 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m assert(answers); - for (j = 0, k = 0; k < nr; k++) { + for (k = 0; k < nr; k++) { if (answers[k].type != RFC1035_TYPE_A) continue; @@ -685,6 +686,23 @@ ipcacheInvalidate(const char *name) */ } +void +ipcacheInvalidateNegative(const char *name) +{ + ipcache_entry *i; + + if ((i = ipcache_get(name)) == NULL) + return; + + if (i->flags.negcached) + i->expires = squid_curtime; + + /* + * NOTE, don't call ipcacheRelease here becuase we might be here due + * to a thread started from a callback. + */ +} + ipcache_addrs * ipcacheCheckNumeric(const char *name) { @@ -799,6 +817,7 @@ ipcacheMarkBadAddr(const char *name, struct in_addr addr) { ia->bad_mask[k] = TRUE; ia->badcount++; + i->expires = XMIN(squid_curtime + XMAX((time_t)60, Config.negativeDnsTtl), i->expires); debug(14, 2) ("ipcacheMarkBadAddr: %s [%s]\n", name, inet_ntoa(addr)); } diff --git a/src/protos.h b/src/protos.h index cd71c66d5b..c9da70aaad 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.495 2004/08/30 05:12:31 robertc Exp $ + * $Id: protos.h,v 1.496 2004/10/18 12:20:10 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -487,10 +487,9 @@ SQUIDCEXTERN void ipcache_nbgethostbyname(const char *name, SQUIDCEXTERN EVH ipcache_purgelru; SQUIDCEXTERN const ipcache_addrs *ipcache_gethostbyname(const char *, int flags); SQUIDCEXTERN void ipcacheInvalidate(const char *); -SQUIDCEXTERN void ipcacheReleaseInvalid(const char *); +SQUIDCEXTERN void ipcacheInvalidateNegative(const char *); SQUIDCEXTERN void ipcache_init(void); SQUIDCEXTERN void stat_ipcache_get(StoreEntry *); -SQUIDCEXTERN int ipcacheQueueDrain(void); SQUIDCEXTERN void ipcacheCycleAddr(const char *name, ipcache_addrs *); SQUIDCEXTERN void ipcacheMarkBadAddr(const char *name, struct in_addr); diff --git a/src/structs.h b/src/structs.h index 321be0dfa5..2ac1adf719 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.492 2004/10/14 23:31:30 hno Exp $ + * $Id: structs.h,v 1.493 2004/10/18 12:20:10 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -556,6 +556,7 @@ struct _SquidConfig #endif int request_entities; + int balance_on_multiple_ip; int check_hostnames; int via; int emailErrData;