#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 connFinishedWithConn (int size)=0
 ?? 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...
 
virtual void * toCbdata ()=0
 
virtual void noteMoreBodySpaceAvailable (RefCount< BodyPipe > bp)=0
 
virtual void noteBodyConsumerAborted (RefCount< BodyPipe > bp)=0
 

Static Public Member Functions

static Pointer Start (AsyncJob *job)
 starts a freshly created job (i.e., makes the job asynchronous) More...
 

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

Protected Member Functions

void doClientRead (const CommIoCbParams &io)
 
void clientWriteDone (const CommIoCbParams &io)
 
virtual void checkLogging ()=0
 Log the current [attempt at] transaction if nobody else will. More...
 
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...
 
const InstanceId< AsyncJobid
 job identifier More...
 

Detailed Description

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

Definition at line 28 of file Server.h.

Member Typedef Documentation

◆ Pointer [1/2]

Definition at line 25 of file BodyPipe.h.

◆ Pointer [2/2]

Definition at line 34 of file AsyncJob.h.

Constructor & Destructor Documentation

◆ Server()

Server::Server ( const MasterXactionPointer xact)

Definition at line 24 of file Server.cc.

◆ ~Server()

virtual Server::~Server ( )
inlinevirtual

Member Function Documentation

◆ afterClientRead()

virtual void Server::afterClientRead ( )
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead(), and ~Server().

◆ afterClientWrite()

virtual void Server::afterClientWrite ( size_t  )
inlinevirtual

Reimplemented in ConnStateData.

Definition at line 83 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 101 of file AsyncJob.cc.

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

Referenced by AsyncJob::swanSong().

◆ checkLogging()

virtual void Server::checkLogging ( )
protectedpure virtual

Implemented in ConnStateData.

Referenced by doClientRead().

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

◆ connFinishedWithConn()

virtual bool Server::connFinishedWithConn ( int  size)
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead(), and ~Server().

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited

◆ doClientRead()

◆ done()

◆ doneAll()

bool Server::doneAll ( ) const
virtual

Reimplemented from AsyncJob.

Reimplemented in ConnStateData.

Definition at line 33 of file Server.cc.

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

Referenced by ~Server().

◆ 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(), and ~Server().

◆ 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 70 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(), and writing().

◆ mustStop()

void AsyncJob::mustStop ( const char *  aReason)
protectedinherited

Definition at line 69 of file AsyncJob.cc.

References debugs, AsyncJob::inCall, Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.

Referenced by HttpStateData::abortAll(), Ftp::Client::abortAll(), Comm::TcpAcceptor::acceptOne(), Adaptation::Ecap::XactionRep::adaptationAborted(), Adaptation::AccessCheck::callBack(), AsyncJob::callException(), Security::PeerConnector::connectionClosed(), HttpStateData::continueAfterParsingHeader(), Ftp::Client::ctrlClosed(), Adaptation::Iterator::handleAdaptationBlock(), Adaptation::Iterator::handleAdaptationError(), Log::TcpLogger::handleClosure(), Adaptation::Icap::Xaction::handleCommClosed(), Http::Tunneler::handleConnectionClosure(), Mgr::Forwarder::handleError(), Ipc::Forwarder::handleError(), Ipc::Forwarder::handleException(), Ipc::Inquirer::handleException(), HttpStateData::handleMoreRequestBodyAvailable(), Ipc::Inquirer::handleRemoteAck(), Ipc::Forwarder::handleTimeout(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), Comm::ConnOpener::noteAbort(), Adaptation::Icap::ModXact::noteBodyConsumerAborted(), Snmp::Forwarder::noteCommClosed(), Snmp::Inquirer::noteCommClosed(), Mgr::Inquirer::noteCommClosed(), Mgr::Forwarder::noteCommClosed(), Mgr::StoreToCommWriter::noteCommClosed(), Adaptation::Icap::Xaction::noteCommRead(), Rock::HeaderUpdater::noteDoneReading(), Adaptation::Iterator::noteInitiatorAborted(), Adaptation::Icap::Xaction::noteInitiatorAborted(), Adaptation::Ecap::XactionRep::noteInitiatorAborted(), HttpStateData::readReply(), Comm::ConnOpener::sendAnswer(), Rock::Rebuild::start(), Security::PeerConnector::start(), HttpStateData::start(), Ipc::UdsSender::timedout(), and HttpStateData::wroteLast().

◆ 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 57 of file Server.h.

References NULL, reader, receivedFirstByte(), and stopReading().

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

◆ readSomeData()

◆ receivedFirstByte()

virtual void Server::receivedFirstByte ( )
pure virtual

Implemented in ConnStateData.

Referenced by doClientRead(), and reading().

◆ start()

void Server::start ( )
virtual

Reimplemented from AsyncJob.

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

Definition at line 41 of file Server.cc.

Referenced by ~Server().

◆ Start()

◆ status()

◆ stopProducingFor()

◆ stopReading()

void Server::stopReading ( )

◆ swanSong()

void Server::swanSong ( )
virtual

Reimplemented from AsyncJob.

Reimplemented in ConnStateData.

Definition at line 47 of file Server.cc.

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

Referenced by ConnStateData::swanSong(), and ~Server().

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ write() [1/2]

void Server::write ( MemBuf mb)
inline

◆ write() [2/2]

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

Definition at line 76 of file Server.h.

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

◆ writeSomeData()

virtual void Server::writeSomeData ( )
inlinevirtual

Definition at line 66 of file Server.h.

Referenced by clientWriteDone().

◆ writing()

bool Server::writing ( ) const
inline

Definition at line 86 of file Server.h.

References maybeMakeSpaceAvailable(), NULL, and writer.

Member Data Documentation

◆ clientConnection

Comm::ConnectionPointer Server::clientConnection

Definition at line 97 of file Server.h.

Referenced by Ftp::Server::acceptDataConnection(), Format::Format::assemble(), Auth::UserRequest::authenticate(), ConnStateData::buildFakeRequest(), Http::One::Server::buildHttpRequest(), ConnStateData::buildSslCertGenerationParams(), Ftp::Server::callException(), ClientHttpRequest::calloutsError(), IdentLookup::checkForAsync(), clientAclChecklistFill(), ClientHttpRequest::ClientHttpRequest(), clientIdentDone(), clientNegotiateSSL(), Ftp::Server::clientPinnedConnectionClosed(), ConnStateData::clientPinnedConnectionClosed(), ConnStateData::clientPinnedConnectionRead(), clientProcessRequest(), clientProcessRequestFinished(), ClientSocketContextPushDeferredIfNeeded(), clientSocketRecipient(), clientTunnelOnError(), clientWriteDone(), constructHelperQuery(), Ftp::Server::createDataConnection(), ClientHttpRequest::doCallouts(), doClientRead(), doneAll(), ConnStateData::doneWithControlMsg(), ConnStateData::doPeekAndSpliceStep(), ESIContext::fail(), ConnStateData::fakeAConnectRequest(), ConnStateData::getSslContextDone(), ConnStateData::getSslContextStart(), Ftp::Server::handlePasvReply(), Ftp::Server::handleRequest(), httpsCreate(), httpsEstablish(), httpsSslBumpAccessCheckDone(), httpsSslBumpStep2AccessCheckDone(), Ftp::Server::listenForDataConnection(), IdentLookup::LookupDone(), HttpRequest::manager(), ACLIdent::match(), ClientHttpRequest::noteAdaptationAclCheckDone(), ClientHttpRequest::noteBodyProducerAborted(), parseHttpRequest(), Ftp::Server::parseOneRequest(), ConnStateData::parseTlsHandshake(), ConnStateData::pinConnection(), ConnStateData::postHttpsAccept(), prepareAcceleratedURL(), prepareTransparentURL(), clientReplyContext::processExpired(), clientReplyContext::processMiss(), clientReplyContext::processOnlyIfCachedMiss(), Http::One::Server::processParsedRequest(), clientReplyContext::processReplyAccessResult(), clientReplyContext::purgeFoundObject(), clientReplyContext::purgeRequest(), readSomeData(), PeerSelector::resolveSelected(), clientReplyContext::sendBodyTooLargeError(), ConnStateData::sendControlMsg(), clientReplyContext::sendPreconditionFailedError(), Http::One::Server::setReplyError(), Ftp::Server::shovelUploadData(), ConnStateData::splice(), ClientHttpRequest::sslBumpEstablish(), ClientHttpRequest::sslBumpStart(), ConnStateData::sslCrtdHandleReply(), Http::One::Server::start(), Ftp::Server::start(), ConnStateData::start(), ConnStateData::startPeekAndSplice(), statClientRequests(), stopReading(), ConnStateData::stopReceiving(), ConnStateData::storeTlsContextToCache(), swanSong(), ConnStateData::switchToHttps(), tlsAttemptHandshake(), ConnStateData::transparent(), tunnelStart(), TunnelStateData::TunnelStateData(), ConnStateData::whenClientIpKnown(), write(), Http::One::Server::writeControlMsgAndCall(), Ftp::Server::writeEarlyReply(), Ftp::Server::writeForwardedReplyAndCall(), and Ftp::Server::writeReply().

◆ id

const InstanceId<AsyncJob> AsyncJob::id
protectedinherited

Definition at line 72 of file AsyncJob.h.

◆ inBuf

◆ inCall

◆ pipeline

◆ port

AnyP::PortCfgPointer Server::port

Definition at line 107 of file Server.h.

◆ reader

AsyncCall::Pointer Server::reader
protected

Definition at line 124 of file Server.h.

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

◆ receivedFirstByte_

bool Server::receivedFirstByte_

Definition at line 112 of file Server.h.

Referenced by doClientRead(), and ConnStateData::switchToHttps().

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ 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 104 of file Server.h.

Referenced by buildUrlFromHost(), parseHttpRequest(), prepareAcceleratedURL(), prepareTransparentURL(), ConnStateData::splice(), and ConnStateData::switchToHttps().

◆ typeName

◆ writer

AsyncCall::Pointer Server::writer
protected

Definition at line 125 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