#include <FwdState.h>

Inheritance diagram for FwdState:
Collaboration diagram for FwdState:

Public Types

typedef RefCount< FwdStatePointer

Public Member Functions

virtual ~FwdState ()
void startConnectionOrFail ()
void fail (ErrorState *err)
void unregister (Comm::ConnectionPointer &conn)
void unregister (int fd)
void complete ()
void handleUnregisteredServerEnd ()
int reforward ()
bool reforwardableStatus (const Http::StatusCode s) const
void serverClosed (int fd)
void connectStart ()
void connectDone (const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno)
void connectTimeout (int fd)
bool checkRetry ()
bool checkRetriable ()
 Whether we may try sending this request again after a failure. More...
void dispatch ()
Comm::ConnectionPointer pconnPop (const Comm::ConnectionPointer &dest, const char *domain)
void pconnPush (Comm::ConnectionPointer &conn, const char *domain)
bool dontRetry ()
void dontRetry (bool val)
Comm::ConnectionPointer const & serverConnection () const
void startSelectingDestinations (HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
virtual void * toCbdata ()=0

Static Public Member Functions

static void initModule ()
static void Start (const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
 Initiates request forwarding to a peer or origin server. More...
static void fwdStart (const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *)
 Same as Start() but no master xaction info (AccessLogEntry) available. More...
static time_t ForwardTimeout (const time_t fwdStart)
 time left to finish the whole forwarding process (which started at fwdStart) More...
static bool EnoughTimeToReForward (const time_t fwdStart)
static void abort (void *)

Public Attributes

AccessLogEntryPointer al
 info for the future access.log entry More...
bool subscribed = false
 whether noteDestination() and noteDestinationsEnd() calls are allowed More...
AsyncCall::Pointer connector
 a call linking us to the ConnOpener producing serverConn. More...
bool connected_okay
 TCP link ever opened properly. This affects retry of POST,PUT,CONNECT,etc. More...
bool dont_retry
bool forward_completed

Private Types

enum  PconnRace {
 possible pconn race states More...

Private Member Functions

 FwdState (const Comm::ConnectionPointer &client, StoreEntry *, HttpRequest *, const AccessLogEntryPointer &alp)
void start (Pointer aSelf)
void stopAndDestroy (const char *reason)
 ends forwarding; relies on refcounting so the effect may not be immediate More...
virtual void noteDestination (Comm::ConnectionPointer conn) override
 called when a new unique destination has been found More...
virtual void noteDestinationsEnd (ErrorState *selectionError) override
void doneWithRetries ()
void completed ()
void retryOrBail ()
ErrorStatemakeConnectingError (const err_type type) const
void connectedToPeer (Security::EncryptorAnswer &answer)
void closeServerConnection (const char *reason)
 stops monitoring server connection for closure and updates pconn stats More...
void syncWithServerConn (const char *host)
 called when serverConn is set to an open to-peer connection More...
void syncHierNote (const Comm::ConnectionPointer &server, const char *host)
bool exhaustedTries () const
 whether we have used up all permitted forwarding attempts More...

Static Private Member Functions

static void logReplyStatus (int tries, const Http::StatusCode status)
static void RegisterWithCacheManager (void)

Private Attributes

Pointer self
Comm::ConnectionPointer clientConn
 a possibly open connection to the client. More...
time_t start_t
int n_tries
 the number of forwarding attempts so far More...
struct {
   AsyncCall::Pointer   connector
 a call linking us to the ConnOpener producing serverConn. More...
struct {
   bool   connected_okay
 TCP link ever opened properly. This affects retry of POST,PUT,CONNECT,etc. More...
   bool   dont_retry
   bool   forward_completed
Comm::ConnectionList serverDestinations
Comm::ConnectionPointer serverConn
 a successfully opened connection to a server. More...
AsyncCall::Pointer closeHandler
 The serverConn close handler. More...
PconnRace pconnRace
 current pconn race state More...

Detailed Description

Definition at line 59 of file FwdState.h.

Member Typedef Documentation

◆ Pointer

Definition at line 64 of file FwdState.h.

Member Enumeration Documentation

◆ PconnRace

enum FwdState::PconnRace

Definition at line 172 of file FwdState.h.

Constructor & Destructor Documentation

◆ ~FwdState()

◆ FwdState()

FwdState::FwdState ( const Comm::ConnectionPointer client,
StoreEntry e,
HttpRequest r,
const AccessLogEntryPointer alp 

Member Function Documentation

◆ abort()

void FwdState::abort ( void *  d)


FwdState::CBDATA_CHILD ( FwdState  )

◆ checkRetriable()

bool FwdState::checkRetriable ( )

◆ checkRetry()

◆ closeServerConnection()

void FwdState::closeServerConnection ( const char *  reason)

Definition at line 120 of file FwdState.cc.

References comm_remove_close_handler(), debugs, fd_table, PconnPool::noteUses(), and NULL.

Referenced by abort(), and ~FwdState().

◆ complete()

void FwdState::complete ( )

FooClient modules call fwdComplete() when they are done downloading an object. Then, we either 1) re-forward the request somewhere else if needed, or 2) call storeComplete() to finish it off

Definition at line 514 of file FwdState.cc.

References StoreEntry::complete(), completed(), debugs, entry, StoreEntry::getReply(), HERE(), Comm::IsConnOpen(), logReplyStatus(), StoreEntry::mem_obj, n_tries, reforward(), StoreEntry::reset(), serverConn, serverConnection(), serverDestinations, HttpReply::sline, startConnectionOrFail(), Http::StatusLine::status(), stopAndDestroy(), unregister(), and StoreEntry::url().

Referenced by Client::completeForwarding(), connectedToPeer(), dispatch(), gopherReadReply(), gopherStart(), and WhoisState::readReply().

◆ completed()

◆ connectDone()

◆ connectedToPeer()

◆ connectStart()

◆ connectTimeout()

◆ dispatch()

◆ doneWithRetries()

void FwdState::doneWithRetries ( )

Definition at line 707 of file FwdState.cc.

References Http::Message::body_pipe, BodyPipe::expectNoConsumption(), NULL, and request.

Referenced by retryOrBail(), and ~FwdState().

◆ dontRetry() [1/2]

◆ dontRetry() [2/2]

void FwdState::dontRetry ( bool  val)

Definition at line 104 of file FwdState.h.

◆ EnoughTimeToReForward()

bool FwdState::EnoughTimeToReForward ( const time_t  fwdStart)

Whether there is still time to re-try after a previous connection failure.

fwdStartThe start time of the peer selection/connection process.

Definition at line 418 of file FwdState.cc.

References ForwardTimeout().

Referenced by checkRetry(), and TunnelStateData::noteConnectFailure().

◆ exhaustedTries()

bool FwdState::exhaustedTries ( ) const

Definition at line 1266 of file FwdState.cc.

References Config, SquidConfig::forward_max_tries, and n_tries.

Referenced by checkRetry(), and reforward().

◆ fail()

◆ ForwardTimeout()

time_t FwdState::ForwardTimeout ( const time_t  fwdStart)

◆ fwdStart()

void FwdState::fwdStart ( const Comm::ConnectionPointer client,
StoreEntry entry,
HttpRequest request 

Definition at line 394 of file FwdState.cc.

References NULL, and Start().

Referenced by asnCacheStart(), netdbExchangeStart(), ConnStateData::parseTlsHandshake(), and peerDigestRequest().

◆ handleUnregisteredServerEnd()

void FwdState::handleUnregisteredServerEnd ( )

Definition at line 715 of file FwdState.cc.

References assert, debugs, entry, err, HERE(), Comm::IsConnOpen(), retryOrBail(), serverConn, and StoreEntry::url().

Referenced by Client::swanSong().

◆ initModule()

void FwdState::initModule ( )

Definition at line 1240 of file FwdState.cc.

References RegisterWithCacheManager().

Referenced by mainInitialize().

◆ logReplyStatus()

void FwdState::logReplyStatus ( int  tries,
const Http::StatusCode  status 

Definition at line 1252 of file FwdState.cc.

References assert, FwdReplyCodes, MAX_FWD_STATS_IDX, and Http::scInvalidHeader.

Referenced by complete().

◆ makeConnectingError()

ErrorState * FwdState::makeConnectingError ( const err_type  type) const

Create "503 Service Unavailable" or "504 Gateway Timeout" error depending on whether this is a validation request. RFC 2616 says that we MUST reply with "504 Gateway Timeout" if validation fails and cached reply has proxy-revalidate, must-revalidate or s-maxage Cache-Control directive.

Definition at line 1139 of file FwdState.cc.

References HttpRequest::flags, RequestFlags::needValidation, request, Http::scGatewayTimeout, and Http::scServiceUnavailable.

Referenced by connectDone().

◆ noteDestination()

void FwdState::noteDestination ( Comm::ConnectionPointer  path)

Implements PeerSelectionInitiator.

Definition at line 552 of file FwdState.cc.

References serverDestinations, and startConnectionOrFail().

◆ noteDestinationsEnd()

void FwdState::noteDestinationsEnd ( ErrorState error)

called when there will be no more noteDestination() calls

erroris a possible reason why no destinations were found; it is guaranteed to be nil if there was at least one noteDestination() call

Implements PeerSelectionInitiator.

Definition at line 563 of file FwdState.cc.

References debugs, err, fail(), Must, serverDestinations, startConnectionOrFail(), and PeerSelectionInitiator::subscribed.

◆ pconnPop()

Comm::ConnectionPointer FwdState::pconnPop ( const Comm::ConnectionPointer dest,
const char *  domain 

Pops a connection from connection pool if available. If not checks the peer stand-by connection pool for available connection.

Definition at line 1217 of file FwdState.cc.

References SquidConfig::accessList, ACLFilledChecklist::al, al, allow_t::allowed(), checkRetriable(), Config, conn, ACLChecklist::fastCheck(), Comm::Connection::getPeer(), Comm::IsConnOpen(), NULL, PconnPool::pop(), request, SquidConfig::serverPconnForNonretriable, and ACLFilledChecklist::syncAle().

Referenced by connectStart().

◆ pconnPush()

void FwdState::pconnPush ( Comm::ConnectionPointer conn,
const char *  domain 

Decide where details need to be gathered to correctly describe a persistent connection. What is needed:

  • the address/port details about this link
  • domain name of server at other end of this link (either peer or requested host)

Definition at line 1207 of file FwdState.cc.

References Comm::Connection::getPeer(), NULL, and PconnPool::push().

Referenced by HttpStateData::processReplyBody().

◆ reforward()

◆ reforwardableStatus()

◆ RegisterWithCacheManager()

void FwdState::RegisterWithCacheManager ( void  )

Definition at line 1246 of file FwdState.cc.

References fwdStats, and Mgr::RegisterAction().

Referenced by initModule().

◆ retryOrBail()

◆ serverClosed()

void FwdState::serverClosed ( int  fd)

◆ serverConnection()

Comm::ConnectionPointer const& FwdState::serverConnection ( ) const

return a ConnectionPointer to the current server connection (may or may not be open)

Definition at line 107 of file FwdState.h.

References conn, server, and type.

Referenced by abort(), Ftp::Client::Client(), complete(), connectDone(), connectedToPeer(), connectStart(), dispatch(), gopherStart(), HttpStateData::HttpStateData(), serverClosed(), unregister(), and whoisStart().

◆ Start()

void FwdState::Start ( const Comm::ConnectionPointer clientConn,
StoreEntry entry,
HttpRequest request,
const AccessLogEntryPointer al 

This is the entry point for client-side to start forwarding a transaction. It is a static method that may or may not allocate a FwdState.

client_addr == no_addr indicates this is an "internal" request from peer_digest.c, asn.c, netdb.c, etc and should always be allowed. yuck, I know.

Check if this host is allowed to fetch MISSES from us (miss_access). Intentionally replace the src_addr automatically selected by the checklist code we do NOT want the indirect client address to be tested here.

Definition at line 317 of file FwdState.cc.

References SquidConfig::accessList, aclGetDenyInfoPage(), AclMatchedName, ACLFilledChecklist::al, al, HttpRequest::client_addr, Config, debugs, allow_t::denied(), SquidConfig::denyInfoList, ERR_FORWARDING_DENIED, ERR_NONE, ERR_SHUTTING_DOWN, errorAppendEntry(), ACLChecklist::fastCheck(), HttpRequest::flags, FwdState(), CacheManager::GetInstance(), AnyP::Uri::getScheme(), HERE(), RequestFlags::internal, internalStart(), Ip::Address::isNoAddr(), StoreEntry::mem_obj, SquidConfig::miss, NULL, AnyP::PROTO_CACHE_OBJECT, AnyP::PROTO_URN, request, MemObject::request, Http::scForbidden, Http::scServiceUnavailable, shutting_down, ACLFilledChecklist::src_addr, CacheManager::Start(), start(), ACLFilledChecklist::syncAle(), HttpRequest::url, StoreEntry::url(), and urnStart().

Referenced by UrnState::created(), fwdStart(), clientReplyContext::processExpired(), clientReplyContext::processMiss(), and ConnStateData::startPeekAndSplice().

◆ start()

◆ startConnectionOrFail()

void FwdState::startConnectionOrFail ( )

This is the real beginning of server connection. Call it whenever the forwarding server destination has changed and a new one needs to be opened. Produces the cannot-forward error on fail if no better error exists.

Definition at line 424 of file FwdState.cc.

References HttpRequest::clearError(), connectStart(), debugs, entry, err, ERR_CANNOT_FORWARD, fail(), HERE(), AnyP::Uri::host(), NULL, request, Http::scInternalServerError, serverDestinations, stopAndDestroy(), PeerSelectionInitiator::subscribed, syncHierNote(), HttpRequest::url, and StoreEntry::url().

Referenced by complete(), noteDestination(), noteDestinationsEnd(), retryOrBail(), and start().

◆ startSelectingDestinations()

void PeerSelectionInitiator::startSelectingDestinations ( HttpRequest request,
const AccessLogEntry::Pointer ale,
StoreEntry entry 

Initiates asynchronous peer selection that eventually results in zero or more noteDestination() calls and exactly one noteDestinationsEnd() call.

Definition at line 193 of file peer_select.cc.

References peerSelect().

Referenced by start(), and tunnelStart().

◆ stopAndDestroy()

◆ syncHierNote()

void FwdState::syncHierNote ( const Comm::ConnectionPointer server,
const char *  host 

◆ syncWithServerConn()

void FwdState::syncWithServerConn ( const char *  host)

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ unregister() [1/2]

◆ unregister() [2/2]

void FwdState::unregister ( int  fd)

Member Data Documentation

◆ al

◆ calls

struct { ... } FwdState::calls

Referenced by connectStart(), and ~FwdState().

◆ clientConn

Comm::ConnectionPointer FwdState::clientConn

Definition at line 149 of file FwdState.h.

Referenced by connectDone(), dispatch(), and stopAndDestroy().

◆ closeHandler

AsyncCall::Pointer FwdState::closeHandler

Definition at line 169 of file FwdState.h.

Referenced by connectDone(), connectStart(), and unregister().

◆ connected_okay

bool FwdState::connected_okay

Definition at line 159 of file FwdState.h.

◆ connector

AsyncCall::Pointer FwdState::connector

Definition at line 155 of file FwdState.h.

Referenced by connectDone().

◆ dont_retry

bool FwdState::dont_retry

Definition at line 160 of file FwdState.h.

◆ entry

◆ err

◆ flags

struct { ... } FwdState::flags

◆ forward_completed

bool FwdState::forward_completed

Definition at line 161 of file FwdState.h.

◆ n_tries

int FwdState::n_tries

Definition at line 151 of file FwdState.h.

Referenced by complete(), connectStart(), exhaustedTries(), and retryOrBail().

◆ pconnRace

PconnRace FwdState::pconnRace

Definition at line 173 of file FwdState.h.

Referenced by connectStart(), fail(), and retryOrBail().

◆ request

◆ self

Pointer FwdState::self

Definition at line 147 of file FwdState.h.

◆ serverConn

◆ serverDestinations

Comm::ConnectionList FwdState::serverDestinations

◆ start_t

time_t FwdState::start_t

Definition at line 150 of file FwdState.h.

Referenced by checkRetry(), connectDone(), connectStart(), and retryOrBail().

◆ subscribed

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






Web Site Translations