]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Documentation updates and allow const Acceptors to be un-deferred
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 18 Sep 2010 02:12:08 +0000 (14:12 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 18 Sep 2010 02:12:08 +0000 (14:12 +1200)
src/comm/AcceptLimiter.cc
src/comm/AcceptLimiter.h

index b4cbcf1c9e73906d71783656eae1fac9a15ae283..a3ce69935ae8b090e1580716939c3f592bf8aa32 100644 (file)
@@ -20,12 +20,12 @@ Comm::AcceptLimiter::defer(Comm::ConnAcceptor *afd)
 }
 
 void
-Comm::AcceptLimiter::removeDead(Comm::ConnAcceptor *afd)
+Comm::AcceptLimiter::removeDead(const Comm::ConnAcceptor *afd)
 {
     for (unsigned int i = 0; i < deferred.size() && afd->isLimited > 0; i++) {
         if (deferred[i] == afd) {
-            deferred[i] = NULL;
-            afd->isLimited--;
+            deferred[i]->isLimited--;
+            deferred[i] = NULL; // fast. kick() will skip empty entries later.
             debugs(5, 5, HERE << afd->conn << " x" << afd->isLimited);
         }
     }
@@ -34,6 +34,10 @@ Comm::AcceptLimiter::removeDead(Comm::ConnAcceptor *afd)
 void
 Comm::AcceptLimiter::kick()
 {
+    // TODO: this could be optimized further with an iterator to search
+    //       looking for first non-NULL, followed by dumping the first N
+    //       with only one shift()/pop_ftron operation
+
     debugs(5, 5, HERE << " size=" << deferred.size());
     while (deferred.size() > 0 && fdNFree() >= RESERVED_FD) {
         /* NP: shift() is equivalent to pop_front(). Giving us a FIFO queue. */
index 26b8a8e6b62014ed8fd96ab3f3c907f76c956b29..a1dd2f2dc5d72dcf53dd59baa9c9e9c209aba82b 100644 (file)
@@ -29,7 +29,7 @@ public:
     void defer(Comm::ConnAcceptor *afd);
 
     /** remove all records of an acceptor. Only to be called by the ConnAcceptor::swanSong() */
-    void removeDead(Comm::ConnAcceptor *afd);
+    void removeDead(const Comm::ConnAcceptor *afd);
 
     /** try to accept and begin processing any delayed client connections. */
     void kick();