Maintains an fixed-size "standby" PconnPool for a single CachePeer. More...
#include <PeerPoolMgr.h>


Public Types | |
typedef CbcPointer< PeerPoolMgr > | Pointer |
Public Member Functions | |
PeerPoolMgr (CachePeer *aPeer) | |
virtual | ~PeerPoolMgr () |
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 |
Static Public Member Functions | |
static void | Checkpoint (const Pointer &mgr, const char *reason) |
static Pointer | Start (AsyncJob *job) |
starts a freshly created job (i.e., makes the job asynchronous) More... | |
Protected Member Functions | |
virtual void | start () |
called by AsyncStart; do not call directly More... | |
virtual void | swanSong () |
virtual bool | doneAll () const |
whether positive goal has been reached More... | |
bool | validPeer () const |
whether the peer is still out there and in a valid state we can safely use More... | |
void | checkpoint (const char *reason) |
void | openNewConnection () |
starts the process of opening a new standby connection (if possible) More... | |
void | closeOldConnections (const int howMany) |
closes 'howMany' standby connections More... | |
void | handleOpenedConnection (const CommConnectCbParams ¶ms) |
Comm::ConnOpener calls this when done opening a connection for us. More... | |
void | handleSecuredPeer (Security::EncryptorAnswer &answer) |
Security::PeerConnector callback. More... | |
void | handleSecureClosure (const CommCloseCbParams ¶ms) |
called when the connection we are trying to secure is closed by a 3rd party More... | |
void | pushNewConnection (const Comm::ConnectionPointer &conn) |
the final step in connection opening (and, optionally, securing) sequence 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... | |
Protected Attributes | |
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< AsyncJob > | id |
job identifier More... | |
Private Member Functions | |
CBDATA_CLASS (PeerPoolMgr) | |
Private Attributes | |
CachePeer * | peer |
the owner of the pool we manage More... | |
RefCount< HttpRequest > | request |
fake HTTP request for conn opening code More... | |
AsyncCall::Pointer | opener |
whether we are opening a connection More... | |
AsyncCall::Pointer | securer |
whether we are securing a connection More... | |
AsyncCall::Pointer | closer |
monitors conn while we are securing it More... | |
unsigned int | addrUsed |
counter for cycling through peer addresses More... | |
Detailed Description
Definition at line 21 of file PeerPoolMgr.h.
Member Typedef Documentation
◆ Pointer
typedef CbcPointer<PeerPoolMgr> PeerPoolMgr::Pointer |
Definition at line 26 of file PeerPoolMgr.h.
Constructor & Destructor Documentation
◆ PeerPoolMgr()
|
explicit |
Definition at line 43 of file PeerPoolMgr.cc.
Referenced by PeerPoolMgrsRr::syncConfig().
◆ ~PeerPoolMgr()
|
virtual |
Definition at line 53 of file PeerPoolMgr.cc.
References cbdataReferenceDone, and peer.
Member Function Documentation
◆ callEnd()
|
virtualinherited |
called right after the called job method
Reimplemented in Adaptation::Icap::Xaction.
Definition at line 136 of file AsyncJob.cc.
References AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::done(), HERE(), AsyncJob::inCall, NULL, AsyncJob::status(), AsyncJob::swanSong(), and AsyncJob::typeName.
Referenced by Adaptation::Icap::Xaction::callEnd(), AsyncJob::deleteThis(), and AsyncJob::swanSong().
◆ callException()
|
virtualinherited |
Reimplemented in ClientHttpRequest, Adaptation::Icap::ModXact, Adaptation::Icap::Xaction, Adaptation::Icap::ServiceRep, Ftp::Server, Ipc::Forwarder, and Ipc::Inquirer.
Definition at line 127 of file AsyncJob.cc.
References cbdataReferenceValid(), debugs, Must, AsyncJob::mustStop(), and CbdataParent::toCbdata().
Referenced by Ipc::Inquirer::callException(), Ipc::Forwarder::callException(), Ftp::Server::callException(), Adaptation::Icap::Xaction::callException(), and AsyncJob::swanSong().
◆ callStart()
|
inherited |
called just before the called method
Definition at line 114 of file AsyncJob.cc.
References cbdataReferenceValid(), AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::inCall, Must, AsyncJob::status(), CbdataParent::toCbdata(), and AsyncJob::typeName.
Referenced by AsyncJob::swanSong().
◆ canBeCalled()
|
inherited |
Definition at line 101 of file AsyncJob.cc.
References AsyncCall::cancel(), debugs, HERE(), AsyncJob::inCall, and NULL.
Referenced by AsyncJob::swanSong().
◆ CBDATA_CLASS()
|
private |
◆ Checkpoint()
|
static |
Definition at line 261 of file PeerPoolMgr.cc.
References CallJobHere1, and checkpoint().
Referenced by handleSecureClosure(), PconnPool::notifyManager(), peerAlive(), peerConnClosed(), peerDNSConfigure(), and CachePeer::~CachePeer().
◆ checkpoint()
|
protected |
Starts new connection, or closes the excess connections according pool configuration
Definition at line 243 of file PeerPoolMgr.cc.
References closeOldConnections(), PconnPool::count(), debugs, CachePeer::limit, openNewConnection(), peer, CachePeer::pool, CachePeer::standby, and validPeer().
Referenced by Checkpoint(), handleOpenedConnection(), handleSecuredPeer(), and start().
◆ closeOldConnections()
|
protected |
Definition at line 236 of file PeerPoolMgr.cc.
References PconnPool::closeN(), debugs, peer, CachePeer::pool, and CachePeer::standby.
Referenced by checkpoint().
◆ deleteThis()
|
protectedinherited |
Definition at line 49 of file AsyncJob.cc.
References asyncCall(), AsyncJob::callEnd(), debugs, AsyncJob::inCall, JobMemFun(), Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.
◆ done()
|
protectedinherited |
Definition at line 90 of file AsyncJob.cc.
References AsyncJob::doneAll(), NULL, and AsyncJob::stopReason.
Referenced by Adaptation::Ecap::XactionRep::blockVirgin(), AsyncJob::callEnd(), Adaptation::AccessCheck::checkCandidates(), HappyConnOpener::checkForNewConnection(), Rock::Rebuild::checkpoint(), Downloader::downloadFinished(), Comm::TcpAcceptor::handleClosure(), Adaptation::Icap::OptXact::handleCommRead(), Ipc::Inquirer::handleRemoteAck(), Ipc::Inquirer::inquire(), Adaptation::Icap::Launcher::noteAdaptationAnswer(), Adaptation::AccessCheck::noteAnswer(), Adaptation::Icap::Launcher::noteInitiatorAborted(), Adaptation::Icap::Launcher::noteXactAbort(), Ipc::Inquirer::requestTimedOut(), Adaptation::Iterator::step(), Adaptation::AccessCheck::usedDynamicRules(), and Adaptation::Ecap::XactionRep::useVirgin().
◆ doneAll()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 85 of file PeerPoolMgr.cc.
References AsyncJob::doneAll(), CachePeer::limit, peer, CachePeer::standby, and validPeer().
◆ handleOpenedConnection()
|
protected |
Definition at line 91 of file PeerPoolMgr.cc.
References asyncCall(), checkpoint(), Comm::Connection::close(), closer, comm_add_close_handler(), CommCommonCbParams::conn, debugs, Security::PeerOptions::encryptTransport, Comm::Connection::fd, CommCommonCbParams::flag, handleSecureClosure(), handleSecuredPeer(), JobCallback, Must, NULL, Comm::OK, opener, peer, peerConnectFailed(), peerConnectTimeout(), positiveTimeout(), pushNewConnection(), request, CachePeer::secure, securer, squid_curtime, AsyncJob::Start(), Comm::Connection::startTime(), and validPeer().
Referenced by openNewConnection().
◆ handleSecureClosure()
|
protected |
Definition at line 177 of file PeerPoolMgr.cc.
References AsyncCall::cancel(), Checkpoint(), closer, Must, NULL, and securer.
Referenced by handleOpenedConnection().
◆ handleSecuredPeer()
|
protected |
Definition at line 145 of file PeerPoolMgr.cc.
References AsyncCall::cancel(), checkpoint(), Comm::Connection::close(), closer, comm_remove_close_handler(), Security::EncryptorAnswer::conn, debugs, Security::EncryptorAnswer::error, Comm::Connection::fd, CbcPointer< Cbc >::get(), Must, NULL, pushNewConnection(), securer, and validPeer().
Referenced by handleOpenedConnection().
◆ mustStop()
|
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().
◆ openNewConnection()
|
protected |
Definition at line 189 of file PeerPoolMgr.cc.
References CachePeer::addresses, addrUsed, conn, debugs, fdUsageHigh(), GetMarkingsToServer(), getOutgoingAddress(), RefCount< C >::getRaw(), handleOpenedConnection(), CachePeer::http_port, JobCallback, Must, CachePeer::n_addresses, neighborUp(), NULL, opener, peer, peerCanOpenMore(), peerConnectTimeout(), Comm::Connection::peerType, Ip::Address::port(), Comm::Connection::remote, request, securer, Comm::Connection::setPeer(), shutting_down, CachePeer::standby, STANDBY_POOL, AsyncJob::Start(), and CachePeer::waitingForClose.
Referenced by checkpoint().
◆ pushNewConnection()
|
protected |
Definition at line 136 of file PeerPoolMgr.cc.
References Comm::IsConnOpen(), Must, NULL, peer, CachePeer::pool, PconnPool::push(), CachePeer::standby, and validPeer().
Referenced by handleOpenedConnection(), and handleSecuredPeer().
◆ start()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 59 of file PeerPoolMgr.cc.
References checkpoint(), CachePeer::host, AnyP::Uri::host(), XactionInitiator::initPeerPool, Http::METHOD_OPTIONS, peer, AnyP::PROTO_HTTP, request, AsyncJob::start(), and HttpRequest::url.
◆ Start()
|
staticinherited |
Definition at line 23 of file AsyncJob.cc.
References CallJobHere, and AsyncJob::start().
Referenced by Ftp::Server::AcceptCtrlConnection(), Ftp::Server::checkDataConnPre(), clientListenerConnectionOpened(), Ftp::Client::connectDataChannel(), TunnelStateData::connectedToPeer(), FwdState::connectStart(), TunnelStateData::connectToPeer(), Adaptation::Icap::Xaction::dnsLookupDone(), Log::TcpLogger::doConnect(), FwdState::establishTunnelThruProxy(), Ipc::Coordinator::handleCacheMgrRequest(), handleOpenedConnection(), Ipc::Coordinator::handleSnmpRequest(), httpAccept(), httpsAccept(), httpStart(), idnsInitVC(), Adaptation::Initiator::initiateAdaptation(), Ftp::Gateway::listenForDataChannel(), Ftp::Server::listenForDataConnection(), Adaptation::Icap::Xaction::noteCommConnected(), Log::TcpLogger::Open(), HappyConnOpener::openFreshConnection(), openNewConnection(), peerProbeConnect(), Rock::SwapDir::rebuild(), Mgr::FunAction::respond(), Mgr::InfoAction::respond(), FwdState::secureConnectionToPeerIfNeeded(), Ipc::SendMessage(), Mgr::Inquirer::sendResponse(), snmpConstructReponse(), SquidMain(), Ident::Start(), Adaptation::AccessCheck::Start(), CacheManager::start(), Security::PeerConnector::startCertDownloading(), TunnelStateData::startConnecting(), Ftp::StartGateway(), Ftp::StartRelay(), PeerPoolMgrsRr::syncConfig(), and Rock::SwapDir::updateHeaders().
◆ status()
|
protectedvirtualinherited |
for debugging, starts with space
Reimplemented in Adaptation::Icap::ServiceRep, HappyConnOpener, Adaptation::Icap::Xaction, Security::PeerConnector, Adaptation::Ecap::XactionRep, Http::Tunneler, Adaptation::Initiate, Comm::TcpAcceptor, and Ipc::Inquirer.
Definition at line 159 of file AsyncJob.cc.
References MemBuf::append(), Packable::appendf(), buf, MemBuf::content(), NULL, MemBuf::reset(), AsyncJob::stopReason, and MemBuf::terminate().
Referenced by BodyPipe::buf(), AsyncJob::callEnd(), AsyncJob::callStart(), ClientRequestContext::clientAccessCheckDone(), ClientRequestContext::clientRedirectDone(), Ftp::Client::ctrlClosed(), Ftp::Relay::dataChannelConnected(), Ftp::Client::dataClosed(), Ftp::Client::dataComplete(), Ftp::Client::doneSendingRequestBody(), Ftp::Client::handleControlReply(), Ftp::Client::handleEpsvReply(), Ftp::Client::handlePasvReply(), Ftp::Client::parseControlReply(), Ftp::Relay::processReplyBody(), Ftp::Gateway::processReplyBody(), Ftp::Relay::readTransferDoneReply(), Ftp::Client::sendEprt(), Ftp::Client::sendPassive(), Adaptation::Initiate::status(), Comm::TcpAcceptor::status(), and AsyncJob::swanSong().
◆ swanSong()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 73 of file PeerPoolMgr.cc.
References AsyncJob::swanSong().
◆ toCbdata()
|
pure virtualinherited |
Implemented in ClientHttpRequest, HttpStateData, and BodySink.
Referenced by AsyncJob::callException(), AsyncJob::callStart(), and CbdataParent::~CbdataParent().
◆ validPeer()
|
protected |
Definition at line 79 of file PeerPoolMgr.cc.
References cbdataReferenceValid(), peer, CachePeer::pool, and CachePeer::standby.
Referenced by checkpoint(), doneAll(), handleOpenedConnection(), handleSecuredPeer(), and pushNewConnection().
Member Data Documentation
◆ addrUsed
|
private |
Definition at line 69 of file PeerPoolMgr.h.
Referenced by openNewConnection().
◆ closer
|
private |
Definition at line 68 of file PeerPoolMgr.h.
Referenced by handleOpenedConnection(), handleSecureClosure(), and handleSecuredPeer().
◆ id
|
protectedinherited |
Definition at line 72 of file AsyncJob.h.
◆ inCall
|
protectedinherited |
Definition at line 71 of file AsyncJob.h.
Referenced by AsyncJob::callEnd(), Adaptation::Icap::ModXact::callException(), AsyncJob::callStart(), AsyncJob::canBeCalled(), AsyncJob::deleteThis(), Log::TcpLogger::endGracefully(), Log::TcpLogger::handleClosure(), and AsyncJob::mustStop().
◆ opener
|
private |
Definition at line 66 of file PeerPoolMgr.h.
Referenced by handleOpenedConnection(), and openNewConnection().
◆ peer
|
private |
Definition at line 64 of file PeerPoolMgr.h.
Referenced by checkpoint(), closeOldConnections(), doneAll(), handleOpenedConnection(), openNewConnection(), pushNewConnection(), start(), validPeer(), and ~PeerPoolMgr().
◆ request
|
private |
Definition at line 65 of file PeerPoolMgr.h.
Referenced by handleOpenedConnection(), openNewConnection(), and start().
◆ securer
|
private |
Definition at line 67 of file PeerPoolMgr.h.
Referenced by handleOpenedConnection(), handleSecureClosure(), handleSecuredPeer(), and openNewConnection().
◆ stopReason
|
protectedinherited |
Definition at line 69 of file AsyncJob.h.
Referenced by AsyncJob::deleteThis(), AsyncJob::done(), AsyncJob::mustStop(), AsyncJob::status(), Http::Tunneler::status(), Security::PeerConnector::status(), and HappyConnOpener::status().
◆ typeName
|
protectedinherited |
Definition at line 70 of file AsyncJob.h.
Referenced by AsyncJob::AsyncJob(), AsyncJob::callEnd(), Adaptation::Icap::Xaction::callEnd(), AsyncJob::callStart(), AsyncJob::deleteThis(), Adaptation::Icap::Xaction::dieOnConnectionFailure(), Adaptation::Icap::Xaction::disableRepeats(), Adaptation::Icap::Xaction::disableRetries(), Adaptation::Icap::Xaction::handleCommTimedout(), Adaptation::Icap::Xaction::handleSecuredPeer(), AsyncJob::mustStop(), Adaptation::Icap::Xaction::openConnection(), Adaptation::Icap::Xaction::Xaction(), AsyncJob::~AsyncJob(), and Adaptation::Icap::Xaction::~Xaction().
The documentation for this class was generated from the following files:
- src/PeerPoolMgr.h
- src/PeerPoolMgr.cc