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.
/*
- * $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
{
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];
}
if (list == NULL)
return -1;
- int fd = list->findUseableFD();
+ int fd = list->findUseableFD(); // search from the end. skip pending reads.
if (fd >= 0)
{
~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: