]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3753: Removes the domain from the cache_peer server pconn key
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 25 Feb 2013 03:42:35 +0000 (20:42 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 25 Feb 2013 03:42:35 +0000 (20:42 -0700)
Under the squid-3.2 pconn model the IP:port specifying the destination
are part of the key and can be used to strictly filter selection when
locating pconn.  This means the domain is no longer a necessary part
of the key.

Squid using cache_peer can see a large number of wasted idle connections
to their peers due to the key domain value if the peer hostname is not
substituted properly. There is also a similar affect when contacting
servers with virtual hosted domains.

Also bug 3753 was located with peer host and name= values being used
inconsistently as the domain marker. Resulting in failed pop()
operations and extra FD usage.

This has been tested for several months now with only socket usage
benefits seen in several production networks.

NOTE: previous experience some years back with pconn has demonstrated
several broken web servers which assume all requests on a persistent
connection are for the same virtual host. For now this change avoids
altering the behaviour on DIRECT traffic for this reason.

This was sponsored by Treehouse Networks Ltd.

src/forward.cc
src/http.cc

index 9c1a0baf3e2d2650f9a9a95c50754669f1127a52..5d29528a6e2e506717c5a1325378441656e61e22 100644 (file)
@@ -1002,12 +1002,9 @@ FwdState::connectStart()
     }
 
     // Use pconn to avoid opening a new connection.
-    const char *host;
-    if (serverDestinations[0]->getPeer()) {
-        host = serverDestinations[0]->getPeer()->host;
-    } else {
+    const char *host = NULL;
+    if (!serverDestinations[0]->getPeer())
         host = request->GetHost();
-    }
 
     Comm::ConnectionPointer temp;
     // Avoid pconns after races so that the same client does not suffer twice.
@@ -1072,7 +1069,8 @@ FwdState::connectStart()
 
     calls.connector = commCbCall(17,3, "fwdConnectDoneWrapper", CommConnectCbPtrFun(fwdConnectDoneWrapper, this));
     Comm::ConnOpener *cs = new Comm::ConnOpener(serverDestinations[0], calls.connector, ctimeout);
-    cs->setHost(host);
+    if (host)
+        cs->setHost(host);
     AsyncJob::Start(cs);
 }
 
@@ -1322,7 +1320,7 @@ void
 FwdState::pconnPush(Comm::ConnectionPointer &conn, const char *domain)
 {
     if (conn->getPeer()) {
-        fwdPconnPool->push(conn, conn->getPeer()->name);
+        fwdPconnPool->push(conn, NULL);
     } else {
         fwdPconnPool->push(conn, domain);
     }
index 4b2fd8076e1353566cd8d8b3eee6c23dd83275a7..8ee792852e2133de46ca0c1352cac3d2d9fee19c 100644 (file)
@@ -1457,7 +1457,7 @@ HttpStateData::processReplyBody()
                 request->clientConnectionManager->pinConnection(serverConnection, request, _peer,
                         (request->flags.connectionAuth != 0));
             } else {
-                fwd->pconnPush(serverConnection, request->peer_host ? request->peer_host : request->GetHost());
+                fwd->pconnPush(serverConnection, request->GetHost());
             }
 
             serverConnection = NULL;