#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)
 
virtual ~Server ()
 
virtual void start ()
 called by AsyncStart; do not call directly More...
 
virtual bool doneAll () const
 whether positive goal has been reached More...
 
virtual void swanSong ()
 
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)
 

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)
 

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

Detailed Description

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

Definition at line 29 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()

virtual Server::~Server ( )
inlinevirtual

Reimplemented in Ftp::Server, and Http::One::Server.

Definition at line 33 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  )
inlinevirtual

Reimplemented in ConnStateData.

Definition at line 84 of file Server.h.

Referenced by clientWriteDone().

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 102 of file AsyncJob.cc.

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

◆ clientWriteDone()

void Server::clientWriteDone ( const CommIoCbParams io)
protected

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)
protectedinherited

◆ doClientRead()

◆ done()

bool AsyncJob::done ( ) const
protectedinherited

◆ doneAll()

bool Server::doneAll ( ) const
virtual

Reimplemented from AsyncJob.

Reimplemented in ConnStateData.

Definition at line 37 of file Server.cc.

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

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

Definition at line 71 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
inline

Definition at line 58 of file Server.h.

References NULL, and reader.

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

◆ readSomeData()

◆ receivedFirstByte()

virtual void Server::receivedFirstByte ( )
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

◆ shouldCloseOnEof()

virtual bool Server::shouldCloseOnEof ( ) const
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

◆ start()

void Server::start ( )
virtual

Reimplemented from AsyncJob.

Reimplemented in Ftp::Server, Http::One::Server, and ConnStateData.

Definition at line 45 of file Server.cc.

◆ Start()

◆ status()

◆ stopProducingFor()

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

◆ stopReading()

void Server::stopReading ( )

◆ swanSong()

void Server::swanSong ( )
virtual

Reimplemented from AsyncJob.

Reimplemented in ConnStateData.

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 
)
inline

Definition at line 77 of file Server.h.

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

◆ write() [2/2]

void Server::write ( MemBuf mb)
inline

Definition at line 70 of file Server.h.

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

◆ writeSomeData()

virtual void Server::writeSomeData ( )
inlinevirtual

Definition at line 67 of file Server.h.

Referenced by clientWriteDone().

◆ writing()

bool Server::writing ( ) const
inline

Definition at line 87 of file Server.h.

References NULL, and writer.

Member Data Documentation

◆ clientConnection

Comm::ConnectionPointer Server::clientConnection

Definition at line 98 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::clientParseRequests(), 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::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
inherited

Definition at line 73 of file AsyncJob.h.

◆ inBuf

◆ inCall

AsyncCall::Pointer AsyncJob::inCall
protectedinherited

◆ pipeline

◆ port

AnyP::PortCfgPointer Server::port

Definition at line 108 of file Server.h.

◆ reader

AsyncCall::Pointer Server::reader
protected

Definition at line 125 of file Server.h.

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

◆ receivedFirstByte_

bool Server::receivedFirstByte_

◆ started_

bool AsyncJob::started_ = false
protectedinherited

Definition at line 83 of file AsyncJob.h.

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

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ swanSang_

bool AsyncJob::swanSang_ = false
protectedinherited

Definition at line 84 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 105 of file Server.h.

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

◆ typeName

◆ writer

AsyncCall::Pointer Server::writer
protected

Definition at line 126 of file Server.h.

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


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors