From: Jean-Gabriel Dick Date: Fri, 22 Jul 2011 14:42:14 +0000 (-0600) Subject: Bug 1842: Optimize order of tests in peerWouldBePinged() and peerHTTPOkay() X-Git-Tag: SQUID_3_1_15~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9260d17fd2a308770af1e61f42c8675b166261d7;p=thirdparty%2Fsquid.git Bug 1842: Optimize order of tests in peerWouldBePinged() and peerHTTPOkay() The peerAllowedToUse() function may be time consuming, especially on sites that have lots of acls. --- diff --git a/src/neighbors.cc b/src/neighbors.cc index 72fc635492..1618cff537 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -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; }