}
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);
}
}
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. */
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();