]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
04f55905 AJ |
9 | #ifndef _SQUID_SRC_COMM_ACCEPT_LIMITER_H |
10 | #define _SQUID_SRC_COMM_ACCEPT_LIMITER_H | |
11 | ||
69bb9399 | 12 | #include "comm/TcpAcceptor.h" |
04f55905 | 13 | |
f3b976f7 | 14 | #include <deque> |
523c3de3 | 15 | |
97b8ac39 A |
16 | namespace Comm |
17 | { | |
04f55905 | 18 | |
04f55905 AJ |
19 | /** |
20 | * FIFO Queue holding listener socket handlers which have been activated | |
21 | * ready to dupe their FD and accept() a new client connection. | |
22 | * But when doing so there were not enough FD available to handle the | |
23 | * new connection. These handlers are awaiting some FD to become free. | |
24 | * | |
a9870624 | 25 | * defer - used only by Comm layer ConnAcceptor adding themselves when FD are limited. |
166ba587 | 26 | * removeDead - used only by Comm layer ConnAcceptor to remove themselves when dying. |
04f55905 AJ |
27 | * kick - used by Comm layer when FD are closed. |
28 | */ | |
29 | class AcceptLimiter | |
30 | { | |
31 | ||
32 | public: | |
33 | /** retrieve the global instance of the queue. */ | |
34 | static AcceptLimiter &Instance(); | |
35 | ||
36 | /** delay accepting a new client connection. */ | |
69bb9399 | 37 | void defer(const TcpAcceptor::Pointer &afd); |
04f55905 | 38 | |
166ba587 | 39 | /** remove all records of an acceptor. Only to be called by the ConnAcceptor::swanSong() */ |
69bb9399 | 40 | void removeDead(const TcpAcceptor::Pointer &afd); |
166ba587 | 41 | |
04f55905 AJ |
42 | /** try to accept and begin processing any delayed client connections. */ |
43 | void kick(); | |
44 | ||
45 | private: | |
46 | static AcceptLimiter Instance_; | |
47 | ||
48 | /** FIFO queue */ | |
f3b976f7 | 49 | std::deque<TcpAcceptor::Pointer> deferred_; |
04f55905 AJ |
50 | }; |
51 | ||
2f8abb64 | 52 | }; // namespace Comm |
04f55905 AJ |
53 | |
54 | #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */ | |
f53969cc | 55 |