]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/comm/AcceptLimiter.cc
2 * Copyright (C) 1996-2020 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.
10 #include "comm/AcceptLimiter.h"
11 #include "comm/Connection.h"
12 #include "comm/TcpAcceptor.h"
16 Comm::AcceptLimiter
Comm::AcceptLimiter::Instance_
;
19 Comm::AcceptLimiter::Instance()
25 Comm::AcceptLimiter::defer(const Comm::TcpAcceptor::Pointer
&afd
)
27 debugs(5, 5, afd
->conn
<< "; already queued: " << deferred_
.size());
28 deferred_
.push_back(afd
);
32 Comm::AcceptLimiter::removeDead(const Comm::TcpAcceptor::Pointer
&afd
)
34 for (auto it
= deferred_
.begin(); it
!= deferred_
.end(); ++it
) {
36 *it
= nullptr; // fast. kick() will skip empty entries later.
37 debugs(5,4, "Abandoned client TCP SYN by closing socket: " << afd
->conn
);
41 debugs(5,4, "Not found " << afd
->conn
<< " in queue, size: " << deferred_
.size());
45 Comm::AcceptLimiter::kick()
47 debugs(5, 5, "size=" << deferred_
.size());
48 while (deferred_
.size() > 0 && Comm::TcpAcceptor::okToAccept()) {
49 /* NP: shift() is equivalent to pop_front(). Giving us a FIFO queue. */
50 TcpAcceptor::Pointer temp
= deferred_
.front();
51 deferred_
.erase(deferred_
.begin());
53 debugs(5, 5, "doing one.");