From d978c71a145f02173aa57d24489511a45f4d8957 Mon Sep 17 00:00:00 2001 From: amosjeffries <> Date: Sun, 24 Feb 2008 19:06:41 +0000 Subject: [PATCH] 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. --- src/pconn.cc | 6 +++--- src/pconn.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pconn.cc b/src/pconn.cc index d6d3f5f25f..16cd75db85 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.53 2007/05/29 13:31:40 amosjeffries Exp $ + * $Id: pconn.cc,v 1.53.4.1 2008/02/24 12:06:41 amosjeffries 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]; } @@ -284,7 +284,7 @@ PconnPool::pop(const char *host, u_short port, const char *domain, struct IN_ADD 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 a2d4df6ec5..8b08f07e82 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: -- 2.47.3