]> git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/AcceptLimiter.h
Merged from parent (trunk r11240, circa 3.2.0.5+)
[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 ListenStateData adding themselves when FD are limited.
18 * kick - used by Comm layer when FD are closed.
19 */
20 class AcceptLimiter
21 {
22
23 public:
24 /** retrieve the global instance of the queue. */
25 static AcceptLimiter &Instance();
26
27 /** delay accepting a new client connection. */
28 void defer(Comm::TcpAcceptor *afd);
29
30 /** remove all records of an acceptor. Only to be called by the ConnAcceptor::swanSong() */
31 void removeDead(const Comm::TcpAcceptor *afd);
32
33 /** try to accept and begin processing any delayed client connections. */
34 void kick();
35
36 private:
37 static AcceptLimiter Instance_;
38
39 /** FIFO queue */
40 Vector<Comm::TcpAcceptor*> deferred;
41 };
42
43 }; // namepace Comm
44
45 #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */