TcpAcceptor.h
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 #ifndef SQUID_COMM_TCPACCEPTOR_H
10 #define SQUID_COMM_TCPACCEPTOR_H
11 
12 #include "anyp/forward.h"
13 #include "base/AsyncJob.h"
14 #include "base/CbcPointer.h"
15 #include "base/Subscription.h"
16 #include "comm/Flag.h"
17 #include "comm/forward.h"
18 
19 class CommCloseCbParams;
20 
21 namespace Comm
22 {
23 
24 class AcceptLimiter;
25 
38 class TcpAcceptor : public AsyncJob
39 {
41 
42 public:
44 
45 private:
46  virtual void start();
47  virtual bool doneAll() const;
48  virtual void swanSong();
49  virtual const char *status() const;
50 
51  TcpAcceptor(const TcpAcceptor &); // not implemented.
52 
53 public:
54  TcpAcceptor(const Comm::ConnectionPointer &conn, const char *note, const Subscription::Pointer &aSub);
55  TcpAcceptor(const AnyP::PortCfgPointer &listenPort, const char *note, const Subscription::Pointer &aSub);
56 
57 protected:
61  void subscribe(const Subscription::Pointer &aSub);
62 
66  void unsubscribe(const char *reason);
67 
72  void acceptNext();
73 
75  void notify(const Comm::Flag flag, const Comm::ConnectionPointer &details) const;
76 
78  int errcode;
79 
82  static bool okToAccept();
83 
84  friend class AcceptLimiter;
85 
86 private:
88 
92 
95 
98 
100  static void doAccept(int fd, void *data);
101 
102  void acceptOne();
104  void setListen();
105  void handleClosure(const CommCloseCbParams &io);
107  bool intendedForUserConnections() const { return bool(listenPort_); }
108  void logAcceptError(const ConnectionPointer &tcpClient) const;
109 };
110 
111 } // namespace Comm
112 
113 #endif /* SQUID_COMM_TCPACCEPTOR_H */
114 
CBDATA_CLASS(TcpAcceptor)
virtual void start()
called by AsyncStart; do not call directly
Definition: TcpAcceptor.cc:73
AsyncCall::Pointer closer_
listen socket closure handler
Definition: TcpAcceptor.h:97
void handleClosure(const CommCloseCbParams &io)
Definition: TcpAcceptor.cc:191
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
Definition: AcceptLimiter.h:17
CbcPointer< Comm::TcpAcceptor > Pointer
Definition: TcpAcceptor.h:43
ConnectionPointer conn
Definition: TcpAcceptor.h:91
Comm::Flag oldAccept(Comm::ConnectionPointer &details)
Definition: TcpAcceptor.cc:344
TcpAcceptor(const TcpAcceptor &)
virtual const char * status() const
internal cleanup; do not call directly
Definition: TcpAcceptor.cc:124
void unsubscribe(const char *reason)
Definition: TcpAcceptor.cc:66
void notify(const Comm::Flag flag, const Comm::ConnectionPointer &details) const
Call the subscribed callback handler with details about a new connection.
Definition: TcpAcceptor.cc:314
bool intendedForUserConnections() const
whether we are listening on one of the squid.conf *ports
Definition: TcpAcceptor.h:107
Flag
Definition: Flag.h:15
static void doAccept(int fd, void *data)
Method callback for whenever an FD is ready to accept a client connection.
Definition: TcpAcceptor.cc:211
virtual void swanSong()
Definition: TcpAcceptor.cc:108
AnyP::PortCfgPointer listenPort_
configuration details of the listening port (if provided)
Definition: TcpAcceptor.h:94
void logAcceptError(const ConnectionPointer &tcpClient) const
Definition: TcpAcceptor.cc:249
static bool okToAccept()
Definition: TcpAcceptor.cc:233
void subscribe(const Subscription::Pointer &aSub)
Definition: TcpAcceptor.cc:58
virtual bool doneAll() const
whether positive goal has been reached
Definition: TcpAcceptor.cc:91
int errcode
errno code of the last accept() or listen() action if one occurred.
Definition: TcpAcceptor.h:78
Subscription::Pointer theCallSub
used to generate AsyncCalls handling our events.
Definition: TcpAcceptor.h:87

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors