From: Henrik Nordstrom Date: Fri, 14 May 2010 12:34:31 +0000 (+0200) Subject: Reset all addresses as OK after trying them all. This to avoid a "deadlock" X-Git-Tag: SQUID_3_2_0_1~211 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec505200748fdb8da66542cf484223b0bb4eb534;p=thirdparty%2Fsquid.git Reset all addresses as OK after trying them all. This to avoid a "deadlock" when all addresses of the currnet procotol have been marked bad but there remains addresses in another protocol which means there is no addresses we can connect to but unfortunately we don't know that in the current upside-down layering. --- diff --git a/src/comm.cc b/src/comm.cc index 13cb7bcdf9..3c0d020dce 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -704,7 +704,7 @@ comm_openex(int sock_type, AI->ai_socktype = sock_type; AI->ai_protocol = proto; debugs(50, 3, "comm_openex: Attempt fallback open socket for: " << addr ); - new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol); + new_socket = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol); debugs(50, 2, HERE << "attempt open " << note << " socket on: " << addr); } #endif @@ -1051,8 +1051,13 @@ ConnectStateData::commRetryConnect() if (squid_curtime - connstart > Config.Timeout.connect) return 0; } else { - if (tries > addrcount) + if (tries > addrcount) { + /* Flush bad address count in case we are + * skipping over incompatible protocol + */ + ipcacheMarkAllGood(host); return 0; + } } return commResetFD(); diff --git a/src/ipcache.cc b/src/ipcache.cc index 73bfe9bb3b..fc4a69f674 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1067,6 +1067,28 @@ ipcacheMarkBadAddr(const char *name, const Ip::Address &addr) ipcacheCycleAddr(name, ia); } +/// \ingroup IPCacheAPI +void +ipcacheMarkAllGood(const char *name) +{ + ipcache_entry *i; + ipcache_addrs *ia; + int k; + + if ((i = ipcache_get(name)) == NULL) + return; + + ia = &i->addrs; + + /* All bad, reset to All good */ + debugs(14, 3, "ipcacheMarkAllGood: Changing ALL " << name << " addrs to OK (" << ia->badcount << "/" << ia->count << " bad)"); + + for (k = 0; k < ia->count; k++) + ia->bad_mask[k] = 0; + + ia->badcount = 0; +} + /// \ingroup IPCacheAPI void ipcacheMarkGoodAddr(const char *name, const Ip::Address &addr) diff --git a/src/protos.h b/src/protos.h index caccb5851a..9fac2805ab 100644 --- a/src/protos.h +++ b/src/protos.h @@ -333,6 +333,7 @@ SQUIDCEXTERN void stat_ipcache_get(StoreEntry *); SQUIDCEXTERN void ipcacheCycleAddr(const char *name, ipcache_addrs *); SQUIDCEXTERN void ipcacheMarkBadAddr(const char *name, const Ip::Address &); SQUIDCEXTERN void ipcacheMarkGoodAddr(const char *name, const Ip::Address &); +SQUIDCEXTERN void ipcacheMarkAllGood(const char *name); SQUIDCEXTERN void ipcacheFreeMemory(void); SQUIDCEXTERN ipcache_addrs *ipcacheCheckNumeric(const char *name); SQUIDCEXTERN void ipcache_restart(void);