From: hno <> Date: Thu, 19 Jun 2003 19:47:25 +0000 (+0000) Subject: Bugfix for accel mode: Should not reuse persistent connections for X-Git-Tag: SQUID_3_0_PRE1~122 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bd0723adf20ac0ad1c4cb913aece9c94075e9a0d;p=thirdparty%2Fsquid.git Bugfix for accel mode: Should not reuse persistent connections for different domains on the same origin server peer. --- diff --git a/src/forward.cc b/src/forward.cc index 653700477c..c7311e870f 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -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++; diff --git a/src/http.cc b/src/http.cc index 49094bb733..89461127e9 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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); diff --git a/src/pconn.cc b/src/pconn.cc index 96b2a734cb..d0dc6c96f1 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -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) { diff --git a/src/protos.h b/src/protos.h index e22190411d..f248f54be9 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 */