#include <Server.h>

Inheritance diagram for Server:
Collaboration diagram for Server:

Public Types

typedef CbcPointer< AsyncJobPointer
typedef CbcPointer< BodyProducerPointer

Public Member Functions

 Server (const MasterXactionPointer &xact)
 ~Server () override
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
virtual bool shouldCloseOnEof () const =0
 whether to stop serving our client after reading EOF on its connection More...
void readSomeData ()
 maybe grow the inBuf and schedule Comm::Read() More...
virtual bool handleReadData ()=0
virtual void afterClientRead ()=0
 processing to be done after a Comm::Read() More...
bool reading () const
 whether Comm::Read() is scheduled More...
void stopReading ()
 cancels Comm::Read() if it is scheduled More...
virtual void receivedFirstByte ()=0
 Update flags and timeout after the first byte received. More...
virtual void writeSomeData ()
 maybe find some data to send and schedule a Comm::Write() More...
void write (MemBuf *mb)
 schedule some data for a Comm::Write() More...
void write (char *buf, int len)
 schedule some data for a Comm::Write() More...
virtual void afterClientWrite (size_t)
 processing to sync state after a Comm::Write() More...
bool writing () const
 whether Comm::Write() is scheduled More...
void maybeMakeSpaceAvailable ()
 grows the available read buffer space (if possible) More...
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
virtual void noteMoreBodySpaceAvailable (RefCount< BodyPipe > bp)=0
virtual void noteBodyConsumerAborted (RefCount< BodyPipe > bp)=0

Static Public Member Functions

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

Public Attributes

Comm::ConnectionPointer clientConnection
AnyP::ProtocolVersion transferProtocol
AnyP::PortCfgPointer port
 Squid listening port details where this connection arrived. More...
SBuf inBuf
 read I/O buffer for the client connection More...
bool receivedFirstByte_
 true if at least one byte received on this connection More...
Pipeline pipeline
 set of requests waiting to be serviced More...
const InstanceId< AsyncJobid
 job identifier More...

Protected Member Functions

virtual void terminateAll (const Error &, const LogTagsErrors &)=0
 abort any pending transactions and prevent new ones (by closing) More...
void doClientRead (const CommIoCbParams &io)
void clientWriteDone (const CommIoCbParams &io)
void deleteThis (const char *aReason)
void mustStop (const char *aReason)
bool done () const
 the job is destroyed in callEnd() when done() More...
virtual const char * status () const
 internal cleanup; do not call directly More...
void stopProducingFor (RefCount< BodyPipe > &, bool atEof)

Static Protected Member Functions

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

Protected Attributes

AsyncCall::Pointer reader
 set when we are reading More...
AsyncCall::Pointer writer
 set when we are writing 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

virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() More...

Detailed Description

Common base for all Server classes used to manage connections from clients.

Definition at line 31 of file Server.h.

Member Typedef Documentation

◆ Pointer [1/2]

Definition at line 34 of file AsyncJob.h.

◆ Pointer [2/2]

Definition at line 25 of file BodyPipe.h.

Constructor & Destructor Documentation

◆ Server()

Server::Server ( const MasterXactionPointer xact)

Definition at line 26 of file Server.cc.

References clientConnection, and Comm::Connection::leaveOrphanage().

◆ ~Server()

Server::~Server ( )

Definition at line 35 of file Server.h.

Member Function Documentation

◆ afterClientRead()

virtual void Server::afterClientRead ( )
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

◆ afterClientWrite()

virtual void Server::afterClientWrite ( size_t  )

Reimplemented in ConnStateData.

Definition at line 86 of file Server.h.

Referenced by clientWriteDone().

◆ 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.

◆ clientWriteDone()

void Server::clientWriteDone ( const CommIoCbParams io)

callback handling the Comm::Write completion

Will call afterClientWrite(size_t) to sync the I/O state. Then writeSomeData() to initiate any followup writes that could be immediately done.

Definition at line 193 of file Server.cc.

References afterClientWrite(), clientConnection, CommCommonCbParams::conn, debugs, Comm::ERR_CLOSING, Comm::Connection::fd, CommCommonCbParams::flag, Pipeline::front(), Comm::IsConnOpen(), Must, pipeline, CommIoCbParams::size, writer, and writeSomeData().

Referenced by write().

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)

◆ doClientRead()

◆ done()

bool AsyncJob::done ( ) const

◆ doneAll()

bool Server::doneAll ( ) const

Reimplemented from AsyncJob.

Definition at line 37 of file Server.cc.

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

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ handleReadData()

virtual bool Server::handleReadData ( )
pure virtual

called when new request data has been read from the socket

Return values
falsecalled comm_close or setReplyToError (the caller should bail)
truewe did not call comm_close or setReplyToError

Implemented in ConnStateData.

Referenced by doClientRead().

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )

Definition at line 73 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ maybeMakeSpaceAvailable()

void Server::maybeMakeSpaceAvailable ( )

Prepare inBuf for I/O. This method balances several conflicting desires:

  1. Do not read too few bytes at a time.
  2. Do not waste too much buffer space.
  3. Do not [re]allocate or memmove the buffer too much.
  4. Obey Config.maxRequestBufferSize limit.

Definition at line 74 of file Server.cc.

References SBufReservationRequirements::allowShared, CLIENT_REQ_BUF_SZ, Config, debugs, SBufReservationRequirements::idealSpace, inBuf, SBufReservationRequirements::maxCapacity, SquidConfig::maxRequestBufferSize, SBufReservationRequirements::minSpace, SBuf::reserve(), and SBuf::spaceSize().

Referenced by doClientRead().

◆ mustStop()

◆ noteBodyConsumerAborted()

virtual void BodyProducer::noteBodyConsumerAborted ( RefCount< BodyPipe bp)
pure virtualinherited

◆ noteMoreBodySpaceAvailable()

virtual void BodyProducer::noteMoreBodySpaceAvailable ( RefCount< BodyPipe bp)
pure virtualinherited

◆ reading()

bool Server::reading ( ) const

Definition at line 60 of file Server.h.

References reader.

Referenced by doClientRead(), readSomeData(), and stopReading().

◆ readSomeData()

◆ receivedFirstByte()

virtual void Server::receivedFirstByte ( )
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

◆ 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().

◆ shouldCloseOnEof()

virtual bool Server::shouldCloseOnEof ( ) const
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

◆ start()

void Server::start ( )

Reimplemented from AsyncJob.

Definition at line 45 of file Server.cc.

◆ Start()

◆ status()

◆ stopProducingFor()

void BodyProducer::stopProducingFor ( RefCount< BodyPipe > &  p,
bool  atEof 

◆ stopReading()

void Server::stopReading ( )

◆ swanSong()

void Server::swanSong ( )

Reimplemented from AsyncJob.

Definition at line 51 of file Server.cc.

References clientConnection, Comm::Connection::close(), Comm::IsConnOpen(), and AsyncJob::swanSong().

Referenced by ConnStateData::swanSong().

◆ terminateAll()

virtual void Server::terminateAll ( const Error ,
const LogTagsErrors  
protectedpure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

◆ write() [1/2]

void Server::write ( char *  buf,
int  len 

Definition at line 79 of file Server.h.

References clientConnection, clientWriteDone(), JobCallback, Comm::Write(), and writer.

◆ write() [2/2]

void Server::write ( MemBuf mb)

Definition at line 72 of file Server.h.

References clientConnection, clientWriteDone(), JobCallback, Comm::Write(), and writer.

◆ writeSomeData()

virtual void Server::writeSomeData ( )

Definition at line 69 of file Server.h.

Referenced by clientWriteDone().

◆ writing()

bool Server::writing ( ) const

Definition at line 89 of file Server.h.

References writer.

Member Data Documentation

◆ clientConnection

Comm::ConnectionPointer Server::clientConnection

Definition at line 100 of file Server.h.

Referenced by ClientHttpRequest::ClientHttpRequest(), Server(), TunnelStateData::TunnelStateData(), ConnStateData::~ConnStateData(), ConnStateData::abortChunkedRequestBody(), ConnStateData::abortRequestParsing(), ConnStateData::acceptTls(), ConnStateData::afterClientRead(), Format::Format::assemble(), ConnStateData::buildFakeRequest(), IdentLookup::checkForAsync(), ConnStateData::clientAfterReadingRequests(), ConnStateData::clientPinnedConnectionClosed(), ConnStateData::clientPinnedConnectionRead(), ClientRequestContext::clientRedirectDone(), clientSocketRecipient(), clientWriteDone(), ConnStateData::concurrentRequestQueueFilled(), ConnStateData::connStateClosed(), doClientRead(), doneAll(), ConnStateData::doneWithControlMsg(), ConnStateData::doPeekAndSpliceStep(), ConnStateData::endingShutdown(), ConnStateData::extendLifetime(), ConnStateData::fakeAConnectRequest(), ConnStateData::fillConnectionLevelDetails(), ConnStateData::getSslContextDone(), ConnStateData::getSslContextStart(), ConnStateData::handleChunkedRequestBody(), ConnStateData::handleRequestBodyData(), ConnStateData::handleSslBumpHandshakeError(), ClientRequestContext::hostHeaderIpVerify(), ClientRequestContext::hostHeaderVerify(), ClientRequestContext::hostHeaderVerifyFailed(), httpsCreate(), httpsEstablish(), httpsSslBumpAccessCheckDone(), httpsSslBumpStep2AccessCheckDone(), ConnStateData::initiateTunneledRequest(), ConnStateData::isOpen(), ConnStateData::kick(), IdentLookup::LookupDone(), HttpRequest::manager(), ACLIdent::match(), ClientHttpRequest::noteAdaptationAclCheckDone(), ClientHttpRequest::noteBodyProducerAborted(), ConnStateData::parseHttpRequest(), ConnStateData::parseProxyProtocolHeader(), ConnStateData::parseRequests(), ConnStateData::parseTlsHandshake(), ConnStateData::pinConnection(), ConnStateData::postHttpsAccept(), clientReplyContext::processExpired(), clientReplyContext::processMiss(), ConnStateData::proxyProtocolError(), ConnStateData::quitAfterError(), ConnStateData::readNextRequest(), readSomeData(), ConnStateData::resetReadTimeout(), PeerSelector::resolveSelected(), ConnStateData::sendControlMsg(), ConnStateData::serveDelayedError(), ConnStateData::setAuth(), ConnStateData::splice(), ClientRequestContext::sslBumpAccessCheckDone(), ClientHttpRequest::sslBumpEstablish(), ClientHttpRequest::sslBumpStart(), ConnStateData::sslCrtdHandleReply(), ConnStateData::start(), ConnStateData::startPeekAndSplice(), stopReading(), ConnStateData::stopReceiving(), ConnStateData::stopSending(), ConnStateData::storeTlsContextToCache(), ConnStateData::swanSong(), swanSong(), ConnStateData::switchToHttps(), ConnStateData::terminateAll(), ConnStateData::transparent(), ConnStateData::tunnelOnError(), tunnelStart(), ConnStateData::whenClientIpKnown(), and write().

◆ id

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 75 of file AsyncJob.h.

◆ inBuf

◆ inCall

AsyncCall::Pointer AsyncJob::inCall

◆ pipeline

◆ port

AnyP::PortCfgPointer Server::port

Definition at line 110 of file Server.h.

◆ reader

AsyncCall::Pointer Server::reader

Definition at line 127 of file Server.h.

Referenced by doClientRead(), reading(), readSomeData(), and stopReading().

◆ receivedFirstByte_

bool Server::receivedFirstByte_

◆ 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().

◆ transferProtocol

AnyP::ProtocolVersion Server::transferProtocol

The transfer protocol currently being spoken on this connection. HTTP/1.x CONNECT, HTTP/1.1 Upgrade and HTTP/2 SETTINGS offer the ability to change protocols on the fly.

Definition at line 107 of file Server.h.

Referenced by ConnStateData::parseHttpRequest(), ConnStateData::prepareTlsSwitchingURL(), ConnStateData::splice(), and ConnStateData::switchToHttps().

◆ typeName

◆ writer

AsyncCall::Pointer Server::writer

Definition at line 128 of file Server.h.

Referenced by clientWriteDone(), write(), and writing().

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






Web Site Translations