]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 1842: Optimize order of tests in peerWouldBePinged() and peerHTTPOkay()
authorJean-Gabriel Dick <jean-gabriel.dick@curie.fr>
Wed, 20 Jul 2011 07:35:53 +0000 (19:35 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 20 Jul 2011 07:35:53 +0000 (19:35 +1200)
The peerAllowedToUse() function may be time consuming, especially on sites that
have lots of acls.

src/neighbors.cc

index 398ad00141424624a58ec4d38e05ba7ebd6f927e..ae4d6e18b143c0460455a4b923032e243ec4a664 100644 (file)
@@ -213,22 +213,19 @@ peerAllowedToUse(const peer * p, HttpRequest * request)
 static int
 peerWouldBePinged(const peer * p, HttpRequest * request)
 {
-    if (!peerAllowedToUse(p, request))
+    if (p->icp.port == 0)
         return 0;
 
     if (p->options.no_query)
         return 0;
 
-    if (p->options.background_ping && (squid_curtime - p->stats.last_query < Config.backgroundPingRate))
-        return 0;
-
     if (p->options.mcast_responder)
         return 0;
 
     if (p->n_addresses == 0)
         return 0;
 
-    if (p->icp.port == 0)
+    if (p->options.background_ping && (squid_curtime - p->stats.last_query < Config.backgroundPingRate))
         return 0;
 
     /* the case below seems strange, but can happen if the
@@ -237,6 +234,9 @@ peerWouldBePinged(const peer * p, HttpRequest * request)
         if (!request->flags.hierarchical)
             return 0;
 
+    if (!peerAllowedToUse(p, request))
+        return 0;
+
     /* Ping dead peers every timeout interval */
     if (squid_curtime - p->stats.last_query > Config.Timeout.deadPeer)
         return 1;
@@ -251,16 +251,16 @@ peerWouldBePinged(const peer * p, HttpRequest * request)
 int
 peerHTTPOkay(const peer * p, HttpRequest * request)
 {
+    if (p->max_conn)
+        if (p->stats.conn_open >= p->max_conn)
+            return 0;
+
     if (!peerAllowedToUse(p, request))
         return 0;
 
     if (!neighborUp(p))
         return 0;
 
-    if (p->max_conn)
-        if (p->stats.conn_open >= p->max_conn)
-            return 0;
-
     return 1;
 }