From: hno <> Date: Thu, 27 Dec 2007 08:03:13 +0000 (+0000) Subject: Author: Alexey Veselovsky X-Git-Tag: BASIC_TPROXY4~225 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=0c8a9718b41ebc2e092964bc386b2bee9f97bb11;p=thirdparty%2Fsquid.git Author: Alexey Veselovsky Bug #2101: Reuse pconns using LIFO Change the reuse order of persistent connections to LIFO to keep hot connections and let unused connections expire. This is how Squid-2 has been doing things for a long time. --- diff --git a/src/pconn.cc b/src/pconn.cc index 2207115667..f8f2e4bc11 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.54 2007/12/14 23:11:47 amosjeffries Exp $ + * $Id: pconn.cc,v 1.55 2007/12/27 01:03:13 hno Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -139,7 +139,7 @@ IdleConnList::findUseableFD() { assert(nfds); - for (int i = 0; i< nfds; i++) { + for (int i=nfds-1; i>=0; i--) { if (!comm_has_pending_read_callback(fds[i])) { return fds[i]; } @@ -283,7 +283,7 @@ PconnPool::pop(const char *host, u_short port, const char *domain, IPAddress &cl if (list == NULL) return -1; - int fd = list->findUseableFD(); + int fd = list->findUseableFD(); // search from the end. skip pending reads. if (fd >= 0) { diff --git a/src/pconn.h b/src/pconn.h index 6629c72249..be8a7f3584 100644 --- a/src/pconn.h +++ b/src/pconn.h @@ -19,10 +19,10 @@ public: ~IdleConnList(); int numIdle() { return nfds; } - int findFDIndex(int fd); + int findFDIndex(int fd); ///< search from the end of array void removeFD(int fd); void push(int fd); - int findUseableFD(); + int findUseableFD(); ///< find first from the end not pending read fd. void clearHandlers(int fd); private: