]> git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/AcceptLimiter.h
Merged from 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 ListenStateData;
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::ListenStateData *afd);
29
30 /** try to accept and begin processing any delayed client connections. */
31 void kick();
32
33 private:
34 static AcceptLimiter Instance_;
35
36 /** FIFO queue */
37 Vector<Comm::ListenStateData*> deferred;
38 };
39
40 }; // namepace Comm
41
42 #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */