]> 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>
Fri, 22 Jul 2011 14:42:14 +0000 (08:42 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 22 Jul 2011 14:42:14 +0000 (08:42 -0600)
The peerAllowedToUse() function may be time consuming, especially on sites that
have lots of acls.

src/neighbors.cc

index 72fc63549235463bb83b6844badcb7194f0335a9..1618cff53768f9bd4fa585598b936cc21487631c 100644 (file)
@@ -214,22 +214,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
@@ -238,6 +235,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;
@@ -252,16 +252,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;
 }