From: hno <> Date: Sun, 4 Apr 2004 19:44:28 +0000 (+0000) Subject: Bug #865: Persistent connection usage too high after sudden burst of traffic X-Git-Tag: SQUID_3_0_PRE4~1117 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=563103473b9866da44d5ddc9113512ce74e77194;p=thirdparty%2Fsquid.git Bug #865: Persistent connection usage too high after sudden burst of traffic Persistent server connections are reused in a round-robin fashion which may cause the number of connections to stay artificially high after a sudden burst of requests. This patch changes persistent connection management to use a LIFO order reusing the most recently used connection first, thereby allowing unneeded connections to close down by idle timeout. --- diff --git a/src/pconn.cc b/src/pconn.cc index 6bbc8300ee..c51fa30d35 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.42 2004/04/03 14:25:59 hno Exp $ + * $Id: pconn.cc,v 1.43 2004/04/04 13:44:28 hno Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -120,7 +120,7 @@ pconnFindFDIndex (struct _pconn *p, int fd) { int result; - for (result = 0; result < p->nfds; ++result) + for (result = p->nfds - 1; result >= 0; --result) { if (p->fds[result] == fd) return result; @@ -142,7 +142,7 @@ static void pconnPreventHandingOutFD(struct _pconn *p, int fd) { int i = pconnFindFDIndex (p, fd); - assert(i < p->nfds); + assert(i >= 0); debug(48, 3) ("pconnRemoveFD: found FD %d at index %d\n", fd, i); pconnRemoveFDByIndex(p, i); } @@ -319,7 +319,7 @@ pconnPop(const char *host, u_short port, const char *domain) assert(p->nfds > 0); for (int i = 0; i < p->nfds; i++) { - fd = p->fds[0]; + fd = p->fds[p->nfds - 1]; /* If there are pending read callbacks - we're about to close it, so don't issue it! */ if (!comm_has_pending_read_callback(fd)) {