#include <TcpAcceptor.h>

Inheritance diagram for Comm::TcpAcceptor:
Collaboration diagram for Comm::TcpAcceptor:

Public Types

typedef CbcPointer< Comm::TcpAcceptorPointer

Public Member Functions

 TcpAcceptor (const Comm::ConnectionPointer &conn, const char *note, const Subscription::Pointer &aSub)
 TcpAcceptor (const AnyP::PortCfgPointer &listenPort, const char *note, const Subscription::Pointer &aSub)
bool canBeCalled (AsyncCall &call) const
 whether we can be called More...
void callStart (AsyncCall &call)
virtual void callEnd ()
 called right after the called job method More...
virtual void callException (const std::exception &e)
 called when the job throws during an async call More...
void handleStopRequest ()
 process external request to terminate now (i.e. during this async call) More...
virtual void * toCbdata ()=0

Static Public Member Functions

static void Start (const Pointer &job)
static void RegisterWithCacheManager ()

Public Attributes

const InstanceId< AsyncJobid
 job identifier More...

Protected Member Functions

void subscribe (const Subscription::Pointer &aSub)
void unsubscribe (const char *reason)
void acceptNext ()
void notify (const Comm::Flag flag, const Comm::ConnectionPointer &details) const
 Call the subscribed callback handler with details about a new connection. More...
void deleteThis (const char *aReason)
void mustStop (const char *aReason)
bool done () const
 the job is destroyed in callEnd() when done() More...

Static Protected Member Functions

static bool okToAccept ()
static void ReportAllJobs (StoreEntry *)
 writes a cache manager report about all jobs existing in this worker More...

Protected Attributes

int errcode
 errno code of the last accept() or listen() action if one occurred. More...
const char * stopReason
 reason for forcing done() to be true More...
const char * typeName
 kid (leaf) class name, for debugging More...
AsyncCall::Pointer inCall
 the asynchronous call being handled, if any More...
bool started_ = false
 Start() has finished successfully. More...
bool swanSang_ = false
 swanSong() was called More...

Private Member Functions

 CBDATA_CHILD (TcpAcceptor)
void start () override
 called by AsyncStart; do not call directly More...
bool doneAll () const override
 whether positive goal has been reached More...
void swanSong () override
const char * status () const override
 internal cleanup; do not call directly More...
 TcpAcceptor (const TcpAcceptor &)
void acceptOne ()
bool acceptInto (Comm::ConnectionPointer &)
void setListen ()
void handleClosure (const CommCloseCbParams &io)
bool intendedForUserConnections () const
 whether we are listening on one of the squid.conf *ports More...
void logAcceptError (const ConnectionPointer &tcpClient) const
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() More...

Static Private Member Functions

static void doAccept (int fd, void *data)
 Method callback for whenever an FD is ready to accept a client connection. More...

Private Attributes

Subscription::Pointer theCallSub
 used to generate AsyncCalls handling our events. More...
ConnectionPointer conn
AnyP::PortCfgPointer listenPort_
 configuration details of the listening port (if provided) More...
AsyncCall::Pointer closer_
 listen socket closure handler More...


class AcceptLimiter

Detailed Description

Listens on a Comm::Connection for new incoming connections and emits an active Comm::Connection descriptor for the new client.

Handles all event limiting required to quash inbound connection floods within the global FD limits of available Squid_MaxFD and client_ip_max_connections.

Fills the emitted connection with all connection details able to be looked up. Currently these are the local/remote IP:port details and the listening socket transparent-mode flag.

Definition at line 38 of file TcpAcceptor.h.

Member Typedef Documentation

◆ Pointer

Constructor & Destructor Documentation

◆ TcpAcceptor() [1/3]

Comm::TcpAcceptor::TcpAcceptor ( const TcpAcceptor )

◆ TcpAcceptor() [2/3]

Comm::TcpAcceptor::TcpAcceptor ( const Comm::ConnectionPointer conn,
const char *  note,
const Subscription::Pointer aSub 

Definition at line 43 of file TcpAcceptor.cc.

◆ TcpAcceptor() [3/3]

Comm::TcpAcceptor::TcpAcceptor ( const AnyP::PortCfgPointer listenPort,
const char *  note,
const Subscription::Pointer aSub 

Definition at line 51 of file TcpAcceptor.cc.

Member Function Documentation

◆ acceptInto()

◆ acceptNext()

void Comm::TcpAcceptor::acceptNext ( )

Try and accept another connection (synchronous). If one is pending already the subscribed callback handler will be scheduled to handle it before this method returns.

Definition at line 313 of file TcpAcceptor.cc.

References conn, debugs, Comm::IsConnOpen(), and Must.

Referenced by doAccept().

◆ acceptOne()

◆ callEnd()

void AsyncJob::callEnd ( )

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const

Definition at line 117 of file AsyncJob.cc.

References AsyncCall::cancel(), debugs, and AsyncJob::inCall.


Comm::TcpAcceptor::CBDATA_CHILD ( TcpAcceptor  )

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)

◆ doAccept()

void Comm::TcpAcceptor::doAccept ( int  fd,
void *  data 

This private callback is called whenever a filedescriptor is ready to dupe itself and fob off an accept()ed connection

It will either do that accept operation. Or if there are not enough FD available to do the clone safely will push the listening FD into a list of deferred operations. The list gets kicked and the dupe/accept() actually done later when enough sockets become available.

Definition at line 211 of file TcpAcceptor.cc.

References acceptNext(), debugs, Comm::AcceptLimiter::defer(), fatal(), fatalf(), Comm::AcceptLimiter::Instance(), isOpen(), and Must.

◆ done()

bool AsyncJob::done ( ) const

◆ doneAll()

bool Comm::TcpAcceptor::doneAll ( ) const

Reimplemented from AsyncJob.

Definition at line 91 of file TcpAcceptor.cc.

References conn, AsyncJob::doneAll(), and Comm::IsConnOpen().

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ handleClosure()

void Comm::TcpAcceptor::handleClosure ( const CommCloseCbParams io)

called when listening descriptor is closed by an external force such as clientHttpConnectionsClose()

Definition at line 191 of file TcpAcceptor.cc.

References conn, and Must.

Referenced by setListen().

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )

Definition at line 73 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ intendedForUserConnections()

bool Comm::TcpAcceptor::intendedForUserConnections ( ) const

Definition at line 107 of file TcpAcceptor.h.

References listenPort_.

◆ logAcceptError()

◆ mustStop()

◆ notify()

void Comm::TcpAcceptor::notify ( const Comm::Flag  flag,
const Comm::ConnectionPointer details 
) const

◆ okToAccept()

bool Comm::TcpAcceptor::okToAccept ( )

Method to test if there are enough file descriptors to open a new client connection if not the accept() will be postponed

Definition at line 233 of file TcpAcceptor.cc.

References DBG_CRITICAL, debugs, fdNFree(), RESERVED_FD, and squid_curtime.

Referenced by Comm::AcceptLimiter::kick().

◆ RegisterWithCacheManager()

void AsyncJob::RegisterWithCacheManager ( )

Definition at line 215 of file AsyncJob.cc.

References Mgr::RegisterAction(), and AsyncJob::ReportAllJobs().

Referenced by mainInitialize().

◆ ReportAllJobs()

void AsyncJob::ReportAllJobs ( StoreEntry e)

Definition at line 198 of file AsyncJob.cc.

References AllJobs().

Referenced by AsyncJob::RegisterWithCacheManager().

◆ setListen()

void Comm::TcpAcceptor::setListen ( )

New-style listen and accept routines

setListen simply registers our interest in an FD for listening. The constructor takes a callback to call when an FD has been accept()ed some time later.

Definition at line 151 of file TcpAcceptor.cc.

References SquidConfig::accept_filter, comm_add_close_handler(), Config, conn, DBG_CRITICAL, DBG_IMPORTANT, debugs, handleClosure(), JobCallback, Squid_MaxFD, xstrerr(), and xstrncpy().

◆ start()

void Comm::TcpAcceptor::start ( )

Reimplemented from AsyncJob.

Definition at line 75 of file TcpAcceptor.cc.

References COMM_SELECT_READ, conn, debugs, Comm::IsConnOpen(), Must, and Comm::SetSelect().

◆ Start()

◆ status()

const char * Comm::TcpAcceptor::status ( ) const

for debugging, starts with space

Reimplemented from AsyncJob.

Definition at line 124 of file TcpAcceptor.cc.

References MemBuf::append(), Packable::appendf(), conn, MemBuf::content(), MAX_IPSTRLEN, MemBuf::reset(), and AsyncJob::status().

◆ subscribe()

void Comm::TcpAcceptor::subscribe ( const Subscription::Pointer aSub)

Subscribe a handler to receive calls back about new connections. Unsubscribes any existing subscribed handler.

Definition at line 60 of file TcpAcceptor.cc.

References debugs.

◆ swanSong()

void Comm::TcpAcceptor::swanSong ( )

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

◆ unsubscribe()

void Comm::TcpAcceptor::unsubscribe ( const char *  reason)

Remove the currently waiting callback subscription. Already scheduled callbacks remain scheduled.

Definition at line 68 of file TcpAcceptor.cc.

References debugs.

Friends And Related Function Documentation

◆ AcceptLimiter

friend class AcceptLimiter

Definition at line 84 of file TcpAcceptor.h.

Member Data Documentation

◆ closer_

AsyncCall::Pointer Comm::TcpAcceptor::closer_

Definition at line 97 of file TcpAcceptor.h.

◆ conn

ConnectionPointer Comm::TcpAcceptor::conn

conn being listened on for new connections Reserved for read-only use.

Definition at line 91 of file TcpAcceptor.h.

◆ errcode

int Comm::TcpAcceptor::errcode

Definition at line 78 of file TcpAcceptor.h.

◆ id

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 75 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall

◆ listenPort_

AnyP::PortCfgPointer Comm::TcpAcceptor::listenPort_

Definition at line 94 of file TcpAcceptor.h.

Referenced by intendedForUserConnections().

◆ started_

bool AsyncJob::started_ = false

Definition at line 88 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), AsyncJob::callEnd(), and AsyncJob::Start().

◆ stopReason

const char* AsyncJob::stopReason

◆ swanSang_

bool AsyncJob::swanSang_ = false

Definition at line 89 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), and AsyncJob::callEnd().

◆ theCallSub

Subscription::Pointer Comm::TcpAcceptor::theCallSub

Definition at line 87 of file TcpAcceptor.h.

◆ typeName

The documentation for this class was generated from the following files:






Web Site Translations