]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alexey Veselovsky <alexey.veselovsky@eykontech.com>
authorhno <>
Thu, 27 Dec 2007 08:03:13 +0000 (08:03 +0000)
committerhno <>
Thu, 27 Dec 2007 08:03:13 +0000 (08:03 +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 22071156670f5a49bcc6ac3efe7f0af69e8c2c9f..f8f2e4bc118f73a9242c4db84935d4211d15e540 100644 (file)
@@ -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)
     {
index 6629c7224968e9f538241d8271030e9390696db2..be8a7f358482f1455581b7c1fc40d8ad42150134 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: