Coordinates shared activities of Strands (Squid processes or threads) More...
#include <Coordinator.h>
Public Types | |
typedef CbcPointer< AsyncJob > | Pointer |
Public Member Functions | |
Coordinator () | |
void | broadcastSignal (int sig) const |
send sig to registered strands More... | |
const StrandCoords & | strands () const |
currently registered strands 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 |
Static Public Member Functions | |
static Coordinator * | Instance () |
static String | MakeAddr (const char *proccessLabel, int id) |
calculates IPC message address for strand id of processLabel type More... | |
static String | CoordinatorAddr () |
get the IPC message address for coordinator process More... | |
static void | Start (const Pointer &job) |
static void | RegisterWithCacheManager () |
Public Attributes | |
struct sockaddr_un | address |
UDS address from path; treat as read-only. More... | |
const InstanceId< AsyncJob > | id |
job identifier More... | |
Protected Member Functions | |
void | start () override |
called by AsyncStart; do not call directly More... | |
void | receive (const TypedMsgHdr &message) override |
StrandCoord * | findStrand (int kidId) |
registered strand or NULL More... | |
void | registerStrand (const StrandCoord &) |
adds or updates existing More... | |
void | handleRegistrationRequest (const StrandMessage &) |
register,ACK More... | |
void | notifySearcher (const StrandSearchRequest &request, const StrandCoord &) |
answer the waiting search request More... | |
void | handleSearchRequest (const StrandSearchRequest &request) |
answers or queues the request if the answer is not yet known More... | |
void | handleSharedListenRequest (const SharedListenRequest &request) |
returns cached socket or calls openListenSocket() More... | |
void | handleCacheMgrRequest (const Mgr::Request &request) |
void | handleCacheMgrResponse (const Mgr::Response &response) |
void | handleSnmpRequest (const Snmp::Request &request) |
void | handleSnmpResponse (const Snmp::Response &response) |
Comm::ConnectionPointer | openListenSocket (const SharedListenRequest &request, int &errNo) |
calls comm_open_listener() More... | |
bool | doneAll () const override |
whether positive goal has been reached More... | |
void | doListen () |
read the next incoming message More... | |
virtual void | timedout () |
called after setTimeout() if timed out More... | |
Comm::ConnectionPointer & | conn () |
creates if needed and returns raw UDS socket descriptor More... | |
void | setTimeout (time_t seconds, const char *handlerName) |
call timedout() if no UDS messages in a given number of seconds More... | |
void | clearTimeout () |
remove previously set timeout, if any More... | |
void | setOptions (int newOptions) |
changes socket options More... | |
void | deleteThis (const char *aReason) |
void | mustStop (const char *aReason) |
bool | done () const |
the job is destroyed in callEnd() when done() More... | |
virtual void | swanSong () |
virtual const char * | status () const |
internal cleanup; do not call directly More... | |
Static Protected Member Functions | |
static void | ReportAllJobs (StoreEntry *) |
writes a cache manager report about all jobs existing in this worker 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... | |
bool | started_ = false |
Start() has finished successfully. More... | |
bool | swanSang_ = false |
swanSong() was called More... | |
Private Types | |
typedef std::list< StrandSearchRequest > | Searchers |
search requests More... | |
typedef std::map< OpenListenerParams, Comm::ConnectionPointer > | Listeners |
params:connection map More... | |
Private Member Functions | |
CBDATA_CHILD (Coordinator) | |
Coordinator (const Coordinator &) | |
Coordinator & | operator= (const Coordinator &) |
void | noteRead (const CommIoCbParams ¶ms) |
void | receiveOrIgnore (const TypedMsgHdr &) |
receive() but ignore any errors More... | |
void | noteTimeout (const CommTimeoutCbParams &p) |
Comm timeout callback; calls timedout() More... | |
virtual void | finalizedInCbdataChild ()=0 |
hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() More... | |
Private Attributes | |
StrandCoords | strands_ |
registered processes and threads More... | |
Searchers | searchers |
yet unanswered search requests in arrival order More... | |
Listeners | listeners |
cached comm_open_listener() results More... | |
TypedMsgHdr | buf |
msghdr struct filled by Comm More... | |
int | options |
UDS options. More... | |
Comm::ConnectionPointer | conn_ |
UDS descriptor. More... | |
Static Private Attributes | |
static Coordinator * | TheInstance = nullptr |
the only class instance in existence More... | |
Detailed Description
Definition at line 30 of file Coordinator.h.
Member Typedef Documentation
◆ Listeners
|
private |
Definition at line 74 of file Coordinator.h.
◆ Pointer
|
inherited |
Definition at line 34 of file AsyncJob.h.
◆ Searchers
|
private |
Definition at line 71 of file Coordinator.h.
Constructor & Destructor Documentation
◆ Coordinator() [1/2]
Ipc::Coordinator::Coordinator | ( | ) |
Definition at line 34 of file Coordinator.cc.
◆ Coordinator() [2/2]
|
private |
Member Function Documentation
◆ broadcastSignal()
void Ipc::Coordinator::broadcastSignal | ( | int | sig | ) | const |
Definition at line 281 of file Coordinator.cc.
References debugs.
◆ callEnd()
|
virtualinherited |
called right after the called job method
Reimplemented in Adaptation::Icap::Xaction.
Definition at line 152 of file AsyncJob.cc.
References assert, AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::done(), AsyncJob::inCall, AsyncJob::started_, AsyncJob::status(), AsyncJob::swanSang_, AsyncJob::swanSong(), and AsyncJob::typeName.
Referenced by Adaptation::Icap::Xaction::callEnd(), and AsyncJob::deleteThis().
◆ callException()
|
virtualinherited |
Reimplemented in ConnStateData, ClientHttpRequest, Adaptation::Icap::ModXact, Adaptation::Icap::ServiceRep, Adaptation::Icap::Xaction, Ipc::Forwarder, Ipc::Inquirer, and Ftp::Server.
Definition at line 143 of file AsyncJob.cc.
References cbdataReferenceValid(), debugs, Must, AsyncJob::mustStop(), and CbdataParent::toCbdata().
Referenced by ConnStateData::callException(), Adaptation::Icap::Xaction::callException(), Ipc::Forwarder::callException(), Ipc::Inquirer::callException(), and Ftp::Server::callException().
◆ callStart()
|
inherited |
called just before the called method
Definition at line 130 of file AsyncJob.cc.
References cbdataReferenceValid(), AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::inCall, Must, AsyncJob::status(), CbdataParent::toCbdata(), and AsyncJob::typeName.
◆ canBeCalled()
|
inherited |
Definition at line 117 of file AsyncJob.cc.
References AsyncCall::cancel(), debugs, and AsyncJob::inCall.
◆ CBDATA_CHILD()
|
private |
◆ clearTimeout()
|
protectedinherited |
Definition at line 62 of file UdsOp.cc.
References commUnsetConnTimeout(), and conn.
◆ conn()
|
protectedinherited |
Definition at line 41 of file UdsOp.cc.
References COMM_DOBIND, comm_open_uds(), Comm::IsConnOpen(), and Must.
◆ CoordinatorAddr()
|
staticinherited |
Definition at line 65 of file Port.cc.
References String::append(), SBuf::c_str(), channelPathPfx, coordinatorAddrLabel, service_name, and String::size().
Referenced by Ipc::StrandMessage::NotifyCoordinator(), IpcIoFile::open(), Mgr::Action::sendResponse(), Snmp::SendResponse(), SendSharedListenRequest(), and Ipc::Forwarder::start().
◆ deleteThis()
|
protectedinherited |
Definition at line 65 of file AsyncJob.cc.
References asyncCall(), AsyncJob::callEnd(), debugs, AsyncJob::deleteThis(), AsyncJob::inCall, JobMemFun(), Must, AsyncJob::stopReason, and AsyncJob::typeName.
Referenced by ConnStateData::connStateClosed(), and AsyncJob::deleteThis().
◆ doListen()
|
protectedinherited |
Definition at line 37 of file Port.cc.
References comm_read(), conn, debugs, JobCallback, MYNAME, and Ipc::Port::noteRead().
◆ done()
|
protectedinherited |
Definition at line 106 of file AsyncJob.cc.
References AsyncJob::doneAll(), and AsyncJob::stopReason.
Referenced by AsyncJob::callEnd(), HappyConnOpener::checkForNewConnection(), Downloader::downloadFinished(), and HappyConnOpener::maybeOpenPrimeConnection().
◆ doneAll()
|
overrideprotectedvirtualinherited |
◆ finalizedInCbdataChild()
|
privatepure virtualinherited |
◆ findStrand()
|
protected |
Definition at line 44 of file Coordinator.cc.
◆ handleCacheMgrRequest()
|
protected |
Definition at line 167 of file Coordinator.cc.
References action(), Mgr::ActionParams::actionName, Mgr::Request::conn, CacheManager::createRequestedAction(), DBG_IMPORTANT, debugs, Comm::Connection::fd, CacheManager::GetInstance(), MYNAME, Mgr::Response::pack(), Mgr::Request::params, Ipc::Request::requestId, Ipc::Request::requestorId, Ipc::SendMessage(), AsyncJob::Start(), and Ipc::strandAddrLabel.
◆ handleCacheMgrResponse()
|
protected |
Definition at line 193 of file Coordinator.cc.
References Ipc::Inquirer::HandleRemoteAck().
◆ handleRegistrationRequest()
|
protected |
Definition at line 136 of file Coordinator.cc.
References Ipc::StrandCoord::kidId, Ipc::mtStrandRegistered, Ipc::StrandMessage::pack(), Ipc::SendMessage(), Ipc::StrandMessage::strand, and Ipc::strandAddrLabel.
◆ handleSearchRequest()
|
protected |
Definition at line 199 of file Coordinator.cc.
References debugs, Ipc::StrandSearchRequest::requestorId, and Ipc::StrandSearchRequest::tag.
◆ handleSharedListenRequest()
|
protected |
Definition at line 147 of file Coordinator.cc.
References Ipc::OpenListenerParams::addr, debugs, Comm::Connection::fd, Ipc::SharedListenRequest::mapId, Ipc::SharedListenResponse::pack(), Ipc::SharedListenRequest::params, Ipc::SharedListenRequest::requestorId, Ipc::SendMessage(), and Ipc::strandAddrLabel.
◆ handleSnmpRequest()
|
protected |
Definition at line 233 of file Coordinator.cc.
References debugs, MYNAME, Snmp::Response::pack(), Ipc::Request::requestId, Ipc::Request::requestorId, Ipc::SendMessage(), AsyncJob::Start(), and Ipc::strandAddrLabel.
◆ handleSnmpResponse()
|
protected |
Definition at line 246 of file Coordinator.cc.
References debugs, Ipc::Inquirer::HandleRemoteAck(), and MYNAME.
◆ handleStopRequest()
|
inlineinherited |
Definition at line 73 of file AsyncJob.h.
References AsyncJob::mustStop().
◆ Instance()
|
static |
Definition at line 291 of file Coordinator.cc.
Referenced by SquidMain().
◆ MakeAddr()
Definition at line 52 of file Port.cc.
References String::append(), assert, SBuf::c_str(), channelPathPfx, service_name, and xitoa().
Referenced by Ipc::Inquirer::inquire(), IpcIoFile::Notify(), and CollapsedForwarding::Notify().
◆ mustStop()
|
protectedinherited |
Definition at line 85 of file AsyncJob.cc.
References debugs, AsyncJob::inCall, Must, AsyncJob::stopReason, and AsyncJob::typeName.
Referenced by HttpStateData::abortAll(), AsyncJob::callException(), HttpStateData::continueAfterParsingHeader(), HttpStateData::drop1xx(), HttpStateData::handleMoreRequestBodyAvailable(), AsyncJob::handleStopRequest(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), HttpStateData::proceedAfter1xx(), ConnStateData::proxyProtocolError(), HttpStateData::readReply(), HttpStateData::start(), and HttpStateData::wroteLast().
◆ noteRead()
|
privateinherited |
Definition at line 96 of file Port.cc.
References assert, CommIoCbParams::buf, CommCommonCbParams::conn, debugs, CommCommonCbParams::flag, and Comm::OK.
Referenced by Ipc::Port::doListen().
◆ noteTimeout()
|
privateinherited |
Definition at line 67 of file UdsOp.cc.
Referenced by Ipc::UdsOp::setTimeout().
◆ notifySearcher()
|
protected |
Definition at line 220 of file Coordinator.cc.
References debugs, Ipc::StrandCoord::kidId, Ipc::mtStrandReady, Ipc::StrandMessage::pack(), Ipc::StrandSearchRequest::qid, Ipc::StrandSearchRequest::requestorId, Ipc::SendMessage(), Ipc::strandAddrLabel, and Ipc::StrandSearchRequest::tag.
◆ openListenSocket()
|
protected |
Definition at line 254 of file Coordinator.cc.
References Ipc::OpenListenerParams::addr, comm_open_listener(), debugs, enter_suid(), Ipc::FdNote(), Ipc::OpenListenerParams::fdNote, Comm::Connection::flags, Ipc::OpenListenerParams::flags, Comm::IsConnOpen(), leave_suid(), Comm::Connection::local, Ipc::SharedListenRequest::params, Ipc::OpenListenerParams::proto, Ipc::SharedListenRequest::requestorId, and Ipc::OpenListenerParams::sock_type.
◆ operator=()
|
private |
◆ receive()
|
overrideprotectedvirtual |
handle IPC message just read kids must call parent method when they do not recognize the message type
Implements Ipc::Port.
Definition at line 79 of file Coordinator.cc.
References debugs, Ipc::Mine(), Ipc::mtCacheMgrRequest, Ipc::mtCacheMgrResponse, Ipc::mtFindStrand, Ipc::mtRegisterStrand, Ipc::mtSharedListenRequest, Ipc::mtSnmpRequest, Ipc::mtSnmpResponse, Ipc::TypedMsgHdr::rawType(), Ipc::Port::receive(), Ipc::StrandSearchRequest::requestorId, and Ipc::StrandSearchRequest::tag.
◆ receiveOrIgnore()
|
privateinherited |
Definition at line 85 of file Port.cc.
References CurrentException(), DBG_IMPORTANT, debugs, Debug::Extra(), and Ipc::TypedMsgHdr::rawType().
◆ registerStrand()
|
protected |
Definition at line 54 of file Coordinator.cc.
References debugs, Ipc::StrandCoord::kidId, String::size(), and Ipc::StrandCoord::tag.
◆ RegisterWithCacheManager()
|
staticinherited |
Definition at line 215 of file AsyncJob.cc.
References Mgr::RegisterAction(), and AsyncJob::ReportAllJobs().
Referenced by mainInitialize().
◆ ReportAllJobs()
|
staticprotectedinherited |
Definition at line 198 of file AsyncJob.cc.
References AllJobs().
Referenced by AsyncJob::RegisterWithCacheManager().
◆ setOptions()
|
protectedinherited |
Definition at line 35 of file UdsOp.cc.
Referenced by Ipc::Port::Port().
◆ setTimeout()
|
protectedinherited |
Definition at line 54 of file UdsOp.cc.
References asyncCall(), commSetConnTimeout(), conn, handler(), and Ipc::UdsOp::noteTimeout().
◆ start()
|
overrideprotectedvirtual |
◆ Start()
|
staticinherited |
Promises to start the configured job (eventually). The job is deemed to be running asynchronously beyond this point, so the caller should only access the job object via AsyncCalls rather than directly.
swanSong() is only called for jobs for which this method has returned successfully (i.e. without throwing).
Definition at line 37 of file AsyncJob.cc.
References CallJobHere, AsyncJob::start(), and AsyncJob::started_.
Referenced by Ftp::Server::AcceptCtrlConnection(), clientListenerConnectionOpened(), handleCacheMgrRequest(), handleSnmpRequest(), httpAccept(), httpsAccept(), httpStart(), idnsInitVC(), Ftp::Gateway::listenForDataChannel(), Ftp::Server::listenForDataConnection(), Log::TcpLogger::Open(), peerProbeConnect(), Mgr::FunAction::respond(), Mgr::InfoAction::respond(), Ipc::SendMessage(), Mgr::Inquirer::sendResponse(), snmpConstructReponse(), SquidMain(), CacheManager::start(), Adaptation::AccessCheck::Start(), Rock::Rebuild::Start(), JobWaitBase::start_(), BodyPipe::startAutoConsumptionIfNeeded(), Ftp::StartGateway(), Ftp::StartRelay(), PeerPoolMgrsRr::syncConfig(), and Rock::SwapDir::updateHeaders().
◆ status()
|
protectedvirtualinherited |
for debugging, starts with space
Reimplemented in Adaptation::Ecap::XactionRep, Adaptation::Icap::ServiceRep, Adaptation::Icap::Xaction, Adaptation::Initiate, Http::Tunneler, Comm::TcpAcceptor, HappyConnOpener, Ipc::Inquirer, and Security::PeerConnector.
Definition at line 182 of file AsyncJob.cc.
References MemBuf::append(), Packable::appendf(), MemBuf::content(), MemBuf::reset(), AsyncJob::stopReason, and MemBuf::terminate().
Referenced by AsyncJob::callEnd(), AsyncJob::callStart(), Adaptation::Initiate::status(), and Comm::TcpAcceptor::status().
◆ strands()
const Ipc::StrandCoords & Ipc::Coordinator::strands | ( | ) | const |
Definition at line 302 of file Coordinator.cc.
◆ swanSong()
|
inlineprotectedvirtualinherited |
Reimplemented in Adaptation::Ecap::XactionRep, Adaptation::Icap::Launcher, Adaptation::Icap::ModXact, Adaptation::Icap::ModXactLauncher, Adaptation::Icap::OptXact, Adaptation::Icap::Xaction, Adaptation::Initiate, Adaptation::Iterator, ConnStateData, Client, Ftp::Relay, Http::Tunneler, Comm::ConnOpener, Comm::TcpAcceptor, Downloader, Rock::HeaderUpdater, Rock::Rebuild, HappyConnOpener, Ipc::Forwarder, Ipc::Inquirer, Ipc::UdsSender, Log::TcpLogger, Mgr::Filler, Mgr::Forwarder, Mgr::StoreToCommWriter, PeerPoolMgr, Security::PeerConnector, Server, and Snmp::Forwarder.
Definition at line 61 of file AsyncJob.h.
Referenced by AsyncJob::callEnd(), Client::swanSong(), Http::Tunneler::swanSong(), Comm::ConnOpener::swanSong(), Comm::TcpAcceptor::swanSong(), Rock::HeaderUpdater::swanSong(), HappyConnOpener::swanSong(), Ipc::UdsSender::swanSong(), Log::TcpLogger::swanSong(), PeerPoolMgr::swanSong(), Security::PeerConnector::swanSong(), and Server::swanSong().
◆ timedout()
|
inlineprotectedvirtualinherited |
Reimplemented in Ipc::Strand, and Ipc::UdsSender.
◆ toCbdata()
|
pure virtualinherited |
Referenced by AsyncJob::callException(), and AsyncJob::callStart().
Member Data Documentation
◆ address
|
inherited |
Definition at line 37 of file UdsOp.h.
Referenced by Ipc::UdsSender::UdsSender().
◆ buf
|
privateinherited |
◆ conn_
|
privateinherited |
◆ id
|
inherited |
Definition at line 75 of file AsyncJob.h.
◆ inCall
|
protectedinherited |
Definition at line 86 of file AsyncJob.h.
Referenced by AsyncJob::callEnd(), AsyncJob::callStart(), AsyncJob::canBeCalled(), AsyncJob::deleteThis(), and AsyncJob::mustStop().
◆ listeners
|
private |
Definition at line 75 of file Coordinator.h.
◆ options
◆ searchers
|
private |
Definition at line 72 of file Coordinator.h.
◆ started_
|
protectedinherited |
Definition at line 88 of file AsyncJob.h.
Referenced by AsyncJob::~AsyncJob(), AsyncJob::callEnd(), and AsyncJob::Start().
◆ stopReason
|
protectedinherited |
Definition at line 84 of file AsyncJob.h.
Referenced by AsyncJob::deleteThis(), AsyncJob::done(), AsyncJob::mustStop(), AsyncJob::status(), and HappyConnOpener::status().
◆ strands_
|
private |
Definition at line 69 of file Coordinator.h.
◆ swanSang_
|
protectedinherited |
Definition at line 89 of file AsyncJob.h.
Referenced by AsyncJob::~AsyncJob(), and AsyncJob::callEnd().
◆ TheInstance
|
staticprivate |
Definition at line 77 of file Coordinator.h.
◆ typeName
|
protectedinherited |
Definition at line 85 of file AsyncJob.h.
Referenced by AsyncJob::AsyncJob(), Adaptation::Icap::Xaction::Xaction(), AsyncJob::~AsyncJob(), AsyncJob::callEnd(), AsyncJob::callStart(), AsyncJob::deleteThis(), and AsyncJob::mustStop().
The documentation for this class was generated from the following files:
- src/ipc/Coordinator.h
- src/ipc/Coordinator.cc