]> git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/AcceptLimiter.h
Sync with trunk
[thirdparty/squid.git] / src / comm / AcceptLimiter.h
1 #ifndef _SQUID_SRC_COMM_ACCEPT_LIMITER_H
2 #define _SQUID_SRC_COMM_ACCEPT_LIMITER_H
3
4 #include "Array.h"
5
6 namespace Comm
7 {
8
9 class TcpAcceptor;
10
11 /**
12 * FIFO Queue holding listener socket handlers which have been activated
13 * ready to dupe their FD and accept() a new client connection.
14 * But when doing so there were not enough FD available to handle the
15 * new connection. These handlers are awaiting some FD to become free.
16 *
17 * defer - used only by Comm layer ConnAcceptor adding themselves when FD are limited.
18 * removeDead - used only by Comm layer ConnAcceptor to remove themselves when dying.
19 * kick - used by Comm layer when FD are closed.
20 */
21 class AcceptLimiter
22 {
23
24 public:
25 /** retrieve the global instance of the queue. */
26 static AcceptLimiter &Instance();
27
28 /** delay accepting a new client connection. */
29 void defer(Comm::TcpAcceptor *afd);
30
31 /** remove all records of an acceptor. Only to be called by the ConnAcceptor::swanSong() */
32 void removeDead(const Comm::TcpAcceptor *afd);
33
34 /** try to accept and begin processing any delayed client connections. */
35 void kick();
36
37 private:
38 static AcceptLimiter Instance_;
39
40 /** FIFO queue */
41 Vector<Comm::TcpAcceptor*> deferred;
42 };
43
44 }; // namepace Comm
45
46 #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */