]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/AcceptLimiter.cc
2 #include "comm/AcceptLimiter.h"
3 #include "comm/Connection.h"
4 #include "comm/TcpAcceptor.h"
7 Comm::AcceptLimiter
Comm::AcceptLimiter::Instance_
;
9 Comm::AcceptLimiter
&Comm::AcceptLimiter::Instance()
15 Comm::AcceptLimiter::defer(Comm::TcpAcceptor
*afd
)
18 debugs(5, 5, HERE
<< afd
->conn
<< " x" << afd
->isLimited
);
19 deferred
.push_back(afd
);
23 Comm::AcceptLimiter::removeDead(const Comm::TcpAcceptor
*afd
)
25 for (unsigned int i
= 0; i
< deferred
.size() && afd
->isLimited
> 0; ++i
) {
26 if (deferred
[i
] == afd
) {
27 -- deferred
[i
]->isLimited
;
28 deferred
[i
] = NULL
; // fast. kick() will skip empty entries later.
29 debugs(5, 5, HERE
<< afd
->conn
<< " x" << afd
->isLimited
);
35 Comm::AcceptLimiter::kick()
37 // TODO: this could be optimized further with an iterator to search
38 // looking for first non-NULL, followed by dumping the first N
39 // with only one shift()/pop_front operation
41 debugs(5, 5, HERE
<< " size=" << deferred
.size());
42 while (deferred
.size() > 0 && fdNFree() >= RESERVED_FD
) {
43 /* NP: shift() is equivalent to pop_front(). Giving us a FIFO queue. */
44 TcpAcceptor
*temp
= deferred
.shift();
46 debugs(5, 5, HERE
<< " doing one.");