AcceptLimiter.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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
17
20{
21 return Instance_;
22}
23
24void
26{
27 debugs(5, 5, afd->conn << "; already queued: " << deferred_.size());
28 deferred_.push_back(afd);
29}
30
31void
33{
34 for (auto it = deferred_.begin(); it != deferred_.end(); ++it) {
35 if (*it == afd) {
36 *it = nullptr; // fast. kick() will skip empty entries later.
37 debugs(5,4, "Abandoned client TCP SYN by closing socket: " << afd->conn);
38 return;
39 }
40 }
41 debugs(5,4, "Not found " << afd->conn << " in queue, size: " << deferred_.size());
42}
43
44void
46{
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());
52 if (temp.valid()) {
53 debugs(5, 5, "doing one.");
54 temp->acceptNext();
55 break;
56 }
57 }
58}
59
Cbc * valid() const
was set and is valid
Definition: CbcPointer.h:41
void defer(const TcpAcceptor::Pointer &afd)
static AcceptLimiter Instance_
Definition: AcceptLimiter.h:46
void removeDead(const TcpAcceptor::Pointer &afd)
static AcceptLimiter & Instance()
static bool okToAccept()
Definition: TcpAcceptor.cc:232
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors