]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/AcceptLimiter.h
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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.
9 #ifndef _SQUID_SRC_COMM_ACCEPT_LIMITER_H
10 #define _SQUID_SRC_COMM_ACCEPT_LIMITER_H
12 #include "comm/TcpAcceptor.h"
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.
25 * defer - used only by Comm layer ConnAcceptor adding themselves when FD are limited.
26 * removeDead - used only by Comm layer ConnAcceptor to remove themselves when dying.
27 * kick - used by Comm layer when FD are closed.
29 /* TODO this algorithm can be optimized further:
31 * 1) reduce overheads by only pushing one entry per port to the list?
32 * use TcpAcceptor::isLimited as a flag whether to re-list when kick()'ing
33 * or to NULL an entry while scanning the list for empty spaces.
34 * Side effect: TcpAcceptor->kick() becomes allowed to pull off multiple accept()'s in bunches
36 * 2) re-implement as a std::queue instead of std::vector
37 * storing head/tail pointers for fast push/pop and avoiding the whole shift() overhead
43 /** retrieve the global instance of the queue. */
44 static AcceptLimiter
&Instance();
46 /** delay accepting a new client connection. */
47 void defer(const TcpAcceptor::Pointer
&afd
);
49 /** remove all records of an acceptor. Only to be called by the ConnAcceptor::swanSong() */
50 void removeDead(const TcpAcceptor::Pointer
&afd
);
52 /** try to accept and begin processing any delayed client connections. */
56 static AcceptLimiter Instance_
;
59 std::vector
<TcpAcceptor::Pointer
> deferred_
;
64 #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */