TcpAcceptor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 
60  void subscribe(const Subscription::Pointer &aSub);
61 
65  void unsubscribe(const char *reason);
66 
71  void acceptNext();
72 
74  void notify(const Comm::Flag flag, const Comm::ConnectionPointer &details) const;
75 
77  int errcode;
78 
81  static bool okToAccept();
82 
83 protected:
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 };
109 
110 } // namespace Comm
111 
112 #endif /* SQUID_COMM_TCPACCEPTOR_H */
113 
bool intendedForUserConnections() const
whether we are listening on one of the squid.conf *ports
Definition: TcpAcceptor.h:107
void unsubscribe(const char *reason)
Definition: TcpAcceptor.cc:68
static void doAccept(int fd, void *data)
Method callback for whenever an FD is ready to accept a client connection.
Definition: TcpAcceptor.cc:221
ConnectionPointer conn
Definition: TcpAcceptor.h:91
AnyP::PortCfgPointer listenPort_
configuration details of the listening port (if provided)
Definition: TcpAcceptor.h:94
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:322
void handleClosure(const CommCloseCbParams &io)
Definition: TcpAcceptor.cc:204
void const char HLPCB void * data
Definition: stub_helper.cc:16
TcpAcceptor(const TcpAcceptor &)
Subscription::Pointer theCallSub
used to generate AsyncCalls handling our events.
Definition: TcpAcceptor.h:87
static bool okToAccept()
Definition: TcpAcceptor.cc:243
virtual const char * status() const
internal cleanup; do not call directly
Definition: TcpAcceptor.cc:124
virtual bool doneAll() const
whether positive goal has been reached
Definition: TcpAcceptor.cc:91
CbcPointer< Comm::TcpAcceptor > Pointer
Definition: TcpAcceptor.h:43
Flag
Definition: Flag.h:15
Comm::Flag oldAccept(Comm::ConnectionPointer &details)
Definition: TcpAcceptor.cc:353
AsyncCall::Pointer closer_
listen socket closure handler
Definition: TcpAcceptor.h:97
virtual void swanSong()
Definition: TcpAcceptor.cc:108
void subscribe(const Subscription::Pointer &aSub)
Definition: TcpAcceptor.cc:60
virtual void start()
called by AsyncStart; do not call directly
Definition: TcpAcceptor.cc:75
CBDATA_CLASS(TcpAcceptor)
int errcode
errno code of the last accept() or listen() action if one occurred.
Definition: TcpAcceptor.h:77

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors