]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Reset all addresses as OK after trying them all. This to avoid a "deadlock"
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Fri, 14 May 2010 12:34:31 +0000 (14:34 +0200)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Fri, 14 May 2010 12:34:31 +0000 (14:34 +0200)
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.

src/comm.cc
src/ipcache.cc
src/protos.h

index 13cb7bcdf931759f10570dafc64a30fe0684cb15..3c0d020dce4b0454bdc40355521c14ef843395f5 100644 (file)
@@ -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();
index 73bfe9bb3b15162ddb0fabe835969cc2048b5439..fc4a69f674a46839a9c914aaf457ef399b3ed5d5 100644 (file)
@@ -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)
index caccb5851a34c93a856df586df3a2841a34b13e2..9fac2805abecef2c7d6c1e57b59013bab14d31d4 100644 (file)
@@ -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);