TcpAcceptor.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
20
21namespace Comm
22{
23
24class AcceptLimiter;
25
38class TcpAcceptor : public AsyncJob
39{
41
42public:
44
45private:
46 void start() override;
47 bool doneAll() const override;
48 void swanSong() override;
49 const char *status() const override;
50
51 TcpAcceptor(const TcpAcceptor &); // not implemented.
52
53public:
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
57protected:
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
79
82 static bool okToAccept();
83
84 friend class AcceptLimiter;
85
86private:
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
AsyncCall::Pointer closer_
listen socket closure handler
Definition: TcpAcceptor.h:97
bool intendedForUserConnections() const
whether we are listening on one of the squid.conf *ports
Definition: TcpAcceptor.h:107
static bool okToAccept()
Definition: TcpAcceptor.cc:233
static void doAccept(int fd, void *data)
Method callback for whenever an FD is ready to accept a client connection.
Definition: TcpAcceptor.cc:211
void start() override
called by AsyncStart; do not call directly
Definition: TcpAcceptor.cc:75
CbcPointer< Comm::TcpAcceptor > Pointer
Definition: TcpAcceptor.h:43
TcpAcceptor(const TcpAcceptor &)
void unsubscribe(const char *reason)
Definition: TcpAcceptor.cc:68
AnyP::PortCfgPointer listenPort_
configuration details of the listening port (if provided)
Definition: TcpAcceptor.h:94
int errcode
errno code of the last accept() or listen() action if one occurred.
Definition: TcpAcceptor.h:78
bool doneAll() const override
whether positive goal has been reached
Definition: TcpAcceptor.cc:91
Subscription::Pointer theCallSub
used to generate AsyncCalls handling our events.
Definition: TcpAcceptor.h:87
void handleClosure(const CommCloseCbParams &io)
Definition: TcpAcceptor.cc:191
void swanSong() override
Definition: TcpAcceptor.cc:108
ConnectionPointer conn
Definition: TcpAcceptor.h:91
CBDATA_CHILD(TcpAcceptor)
const char * status() const override
internal cleanup; do not call directly
Definition: TcpAcceptor.cc:124
bool acceptInto(Comm::ConnectionPointer &)
Definition: TcpAcceptor.cc:345
void subscribe(const Subscription::Pointer &aSub)
Definition: TcpAcceptor.cc:60
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:321
void logAcceptError(const ConnectionPointer &tcpClient) const
Definition: TcpAcceptor.cc:249
Abstraction layer for TCP, UDP, TLS, UDS and filedescriptor sockets.
Definition: AcceptLimiter.h:17
Flag
Definition: Flag.h:15

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors