]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Removes the domain from the cache_peer server pconn key
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 18 Feb 2013 13:02:42 +0000 (02:02 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 18 Feb 2013 13:02:42 +0000 (02:02 +1300)
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 a bug 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 d06577df8a9f95f0116198010da1b7e1f1ced552..3679dd1b27aa3d99571cc7f68d2e937e943cfd47 100644 (file)
@@ -1146,12 +1146,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.
@@ -1216,7 +1213,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);
 }
 
@@ -1466,7 +1464,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 df6fd91600f05d6739a683892a99d0ab49abe574..24f88090ae1671ef31f462e1100f5ffedf8a5e21 100644 (file)
@@ -1445,7 +1445,7 @@ HttpStateData::processReplyBody()
                 request->clientConnectionManager->pinConnection(serverConnection, request, _peer,
                         (request->flags.connectionAuth));
             } else {
-                fwd->pconnPush(serverConnection, request->peer_host ? request->peer_host : request->GetHost());
+                fwd->pconnPush(serverConnection, request->GetHost());
             }
 
             serverConnection = NULL;