Squid Web Cache
master
Loading...
Searching...
No Matches
AcceptLimiter.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2025 The Squid Software Foundation and contributors
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
9
#include "
squid.h
"
10
#include "
comm/AcceptLimiter.h
"
11
#include "
comm/Connection.h
"
12
#include "
comm/TcpAcceptor.h
"
13
#include "
fde.h
"
14
#include "
globals.h
"
15
16
Comm::AcceptLimiter
&
17
Comm::AcceptLimiter::Instance
()
18
{
19
static
const
auto
Instance_ =
new
AcceptLimiter
();
20
return
*Instance_;
21
}
22
23
void
24
Comm::AcceptLimiter::defer
(
const
Comm::TcpAcceptor::Pointer
&afd)
25
{
26
debugs
(5, 5, afd->conn <<
"; already queued: "
<< deferred_.size());
27
deferred_.push_back(afd);
28
}
29
30
void
31
Comm::AcceptLimiter::removeDead
(
const
Comm::TcpAcceptor::Pointer
&afd)
32
{
33
for
(
auto
it = deferred_.begin(); it != deferred_.end(); ++it) {
34
if
(*it == afd) {
35
*it =
nullptr
;
// fast. kick() will skip empty entries later.
36
debugs
(5,4,
"Abandoned client TCP SYN by closing socket: "
<< afd->conn);
37
return
;
38
}
39
}
40
debugs
(5,4,
"Not found "
<< afd->conn <<
" in queue, size: "
<< deferred_.size());
41
}
42
43
void
44
Comm::AcceptLimiter::kick
()
45
{
46
debugs
(5, 5,
"size="
<< deferred_.size());
47
while
(deferred_.size() > 0 &&
Comm::TcpAcceptor::okToAccept
()) {
48
/* NP: shift() is equivalent to pop_front(). Giving us a FIFO queue. */
49
TcpAcceptor::Pointer
temp = deferred_.front();
50
deferred_.erase(deferred_.begin());
51
if
(temp.
valid
()) {
52
debugs
(5, 5,
"doing one."
);
53
temp->acceptNext();
54
break
;
55
}
56
}
57
}
58
AcceptLimiter.h
Connection.h
TcpAcceptor.h
CbcPointer
Definition
CbcPointer.h:26
CbcPointer::valid
Cbc * valid() const
was set and is valid
Definition
CbcPointer.h:41
Comm::AcceptLimiter
Definition
AcceptLimiter.h:30
Comm::AcceptLimiter::defer
void defer(const TcpAcceptor::Pointer &afd)
Definition
AcceptLimiter.cc:24
Comm::AcceptLimiter::kick
void kick()
Definition
AcceptLimiter.cc:44
Comm::AcceptLimiter::removeDead
void removeDead(const TcpAcceptor::Pointer &afd)
Definition
AcceptLimiter.cc:31
Comm::AcceptLimiter::Instance
static AcceptLimiter & Instance()
Definition
AcceptLimiter.cc:17
Comm::TcpAcceptor::okToAccept
static bool okToAccept()
Definition
TcpAcceptor.cc:233
debugs
#define debugs(SECTION, LEVEL, CONTENT)
Definition
Stream.h:192
fde.h
globals.h
squid.h
squid
src
comm
AcceptLimiter.cc
Generated by
1.9.8