]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bugfix for accel mode: Should not reuse persistent connections for
authorhno <>
Thu, 19 Jun 2003 19:47:25 +0000 (19:47 +0000)
committerhno <>
Thu, 19 Jun 2003 19:47:25 +0000 (19:47 +0000)
different domains on the same origin server peer.

src/forward.cc
src/http.cc
src/pconn.cc
src/protos.h

index 653700477c8bbf12afe5fef8052b14d85da45d57..c7311e870f8f0f56fad91f7cbce7ae9cf0e324cb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.102 2003/05/17 17:35:06 hno Exp $
+ * $Id: forward.cc,v 1.103 2003/06/19 13:47:25 hno Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -553,6 +553,7 @@ fwdConnectStart(void *data)
     FwdServer *fs = fwdState->servers;
     const char *host;
     unsigned short port;
+    const char *domain = NULL;
     time_t ctimeout;
 
     struct in_addr outgoing;
@@ -562,10 +563,13 @@ fwdConnectStart(void *data)
     debug(17, 3) ("fwdConnectStart: %s\n", url);
 
     if (fs->_peer) {
-        host = fs->_peer->host;
+        host = fs->_peer->name;
         port = fs->_peer->http_port;
         ctimeout = fs->_peer->connect_timeout > 0 ? fs->_peer->connect_timeout
                    : Config.Timeout.peer_connect;
+
+        if (fs->_peer->options.originserver)
+            domain = fwdState->request->host;
     } else {
         host = fwdState->request->host;
         port = fwdState->request->port;
@@ -573,7 +577,7 @@ fwdConnectStart(void *data)
     }
 
     if (fwdCheckRetriable(fwdState)) {
-        if ((fd = pconnPop(host, port)) >= 0) {
+        if ((fd = pconnPop(host, port, domain)) >= 0) {
             debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd);
             fwdState->server_fd = fd;
             fwdState->n_tries++;
index 49094bb73343e0234e1a06b83b0338e42facf788..89461127e9a43a70298cbe5ec6dec805cf190745 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.414 2003/05/24 11:32:34 robertc Exp $
+ * $Id: http.cc,v 1.415 2003/06/19 13:47:25 hno Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -1014,7 +1014,16 @@ HttpStateData::processReplyData(const char *buf, size_t len)
 
             comm_remove_close_handler(fd, httpStateFree, this);
             fwdUnregister(fd, fwd);
-            pconnPush(fd, request->host, request->port);
+
+            if (_peer) {
+                if (_peer->options.originserver)
+                    pconnPush(fd, _peer->name, orig_request->port, orig_request->host);
+                else
+                    pconnPush(fd, _peer->name, _peer->http_port, NULL);
+            } else {
+                pconnPush(fd, request->host, request->port, NULL);
+            }
+
             fwdComplete(fwd);
             fd = -1;
             httpStateFree(fd, this);
index 96b2a734cb19444d5492d1b43f1da0dc39c6a4e1..d0dc6c96f1dc668bb0690e2069e98d7b81a2709d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pconn.cc,v 1.36 2003/02/21 22:50:10 robertc Exp $
+ * $Id: pconn.cc,v 1.37 2003/06/19 13:47:25 hno Exp $
  *
  * DEBUG: section 48    Persistent Connections
  * AUTHOR: Duane Wessels
@@ -55,7 +55,7 @@ int server_pconn_hist[PCONN_HIST_SZ];
 
 static IOCB pconnRead;
 static PF pconnTimeout;
-static const char *pconnKey(const char *host, u_short port);
+static const char *pconnKey(const char *host, u_short port, const char *domain);
 static hash_table *table = NULL;
 
 static struct _pconn *pconnNew(const char *key);
@@ -70,10 +70,15 @@ CBDATA_TYPE(pconn);
 
 
 static const char *
-pconnKey(const char *host, u_short port)
+pconnKey(const char *host, u_short port, const char *domain)
 {
-    LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN + 10);
-    snprintf(buf, SQUIDHOSTNAMELEN + 10, "%s.%d", host, (int) port);
+    LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN * 2 + 10);
+
+    if (domain)
+        snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d/%s", host, (int) port, domain);
+    else
+        snprintf(buf, SQUIDHOSTNAMELEN * 2 + 10, "%s:%d", host, (int) port);
+
     return buf;
 }
 
@@ -238,7 +243,7 @@ pconnInit(void)
 }
 
 void
-pconnPush(int fd, const char *host, u_short port)
+pconnPush(int fd, const char *host, u_short port, const char *domain)
 {
 
     struct _pconn *p;
@@ -256,7 +261,7 @@ pconnPush(int fd, const char *host, u_short port)
     }
 
     assert(table != NULL);
-    strcpy(key, pconnKey(host, port));
+    strcpy(key, pconnKey(host, port, domain));
 
     p = (struct _pconn *) hash_lookup(table, key);
 
@@ -295,7 +300,7 @@ pconnPush(int fd, const char *host, u_short port)
  * quite a bit of CPU. Just keep it in mind.
  */
 int
-pconnPop(const char *host, u_short port)
+pconnPop(const char *host, u_short port, const char *domain)
 {
 
     struct _pconn *p;
@@ -303,7 +308,7 @@ pconnPop(const char *host, u_short port)
     int fd = -1;
     LOCAL_ARRAY(char, key, SQUIDHOSTNAMELEN + 10);
     assert(table != NULL);
-    strcpy(key, pconnKey(host, port));
+    strcpy(key, pconnKey(host, port, domain));
     hptr = (hash_link *)hash_lookup(table, key);
 
     if (hptr != NULL) {
index e22190411d234c5e6537bd25f533e9e657df1e36..f248f54be944d9f6f8c4d7fb088b2f53985dbeba 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.478 2003/05/18 00:34:50 robertc Exp $
+ * $Id: protos.h,v 1.479 2003/06/19 13:47:25 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -932,8 +932,8 @@ SQUIDCEXTERN void errorStateFree(ErrorState * err);
 SQUIDCEXTERN err_type errorReservePageId(const char *page_name);
 SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status);
 
-SQUIDCEXTERN void pconnPush(int, const char *host, u_short port);
-SQUIDCEXTERN int pconnPop(const char *host, u_short port);
+SQUIDCEXTERN void pconnPush(int, const char *host, u_short port, const char *domain);
+SQUIDCEXTERN int pconnPop(const char *host, u_short port, const char *domain);
 SQUIDCEXTERN void pconnInit(void);
 
 /* tools.c */