]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alexey Veselovsky <alexey.veselovsky@eykontech.com>
authoramosjeffries <>
Sun, 24 Feb 2008 19:06:41 +0000 (19:06 +0000)
committeramosjeffries <>
Sun, 24 Feb 2008 19:06:41 +0000 (19:06 +0000)
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
src/pconn.h

index d6d3f5f25f8286c6cbd0a5a259c50e692bc0adda..16cd75db85cfe42d66afc13a949393a872568e3a 100644 (file)
@@ -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)
     {
index a2d4df6ec51e26c045d00f716185a20649c3ddfa..8b08f07e82df238fc517a8c5f72a8d7fae04b579 100644 (file)
@@ -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: