AcceptLimiter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 #ifndef _SQUID_SRC_COMM_ACCEPT_LIMITER_H
10 #define _SQUID_SRC_COMM_ACCEPT_LIMITER_H
11 
12 #include "comm/TcpAcceptor.h"
13 
14 #include <vector>
15 
16 namespace Comm
17 {
18 
29 /* TODO this algorithm can be optimized further:
30  *
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
35  *
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
38  */
40 {
41 
42 public:
44  static AcceptLimiter &Instance();
45 
47  void defer(const TcpAcceptor::Pointer &afd);
48 
50  void removeDead(const TcpAcceptor::Pointer &afd);
51 
53  void kick();
54 
55 private:
57 
59  std::vector<TcpAcceptor::Pointer> deferred_;
60 };
61 
62 }; // namepace Comm
63 
64 #endif /* _SQUID_SRC_COMM_ACCEPT_LIMITER_H */
65 
std::vector< TcpAcceptor::Pointer > deferred_
Definition: AcceptLimiter.h:59
static AcceptLimiter Instance_
Definition: AcceptLimiter.h:56
void defer(const TcpAcceptor::Pointer &afd)
void removeDead(const TcpAcceptor::Pointer &afd)
static AcceptLimiter & Instance()

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors