]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #862: Repeated POST requests causes number of persistent connections to grow
authorhno <>
Sun, 4 Apr 2004 19:37:20 +0000 (19:37 +0000)
committerhno <>
Sun, 4 Apr 2004 19:37:20 +0000 (19:37 +0000)
If responses to POST or other non-indempotent requests allows the connection
to be kept persistently open then this can lead to a increased connection
usage by Squid. This patch changes the behaviour to keep the number of
connections stable by closing a persistent connection before opening the
new connection.

src/forward.cc

index 81a215da8290155330d636ce02fdf98bde7b0104..e1ffaea9a032ce980c9cf4aeaa0f74d4ce780582 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.116 2004/04/03 14:07:39 hno Exp $
+ * $Id: forward.cc,v 1.117 2004/04/04 13:37:20 hno Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -589,8 +589,8 @@ fwdConnectStart(void *data)
         ctimeout = Config.Timeout.connect;
     }
 
-    if (fwdCheckRetriable(fwdState)) {
-        if ((fd = pconnPop(host, port, domain)) >= 0) {
+    if ((fd = pconnPop(host, port, domain)) >= 0) {
+        if (fwdCheckRetriable(fwdState)) {
             debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd);
             fwdState->server_fd = fd;
             fwdState->n_tries++;
@@ -603,6 +603,12 @@ fwdConnectStart(void *data)
             fwdDispatch(fwdState);
 
             return;
+        } else {
+            /* Discard the persistent connection to not cause
+             * a imbalance in number of conenctions open if there
+             * is a lot of POST requests
+             */
+            comm_close(fd);
         }
     }