#include <helper.h>


Classes | |
struct | _stats |
Public Member Functions | |
void * | operator new (size_t size) |
void | operator delete (void *address) |
void * | toCbdata () noexcept |
helper (const char *name) | |
~helper () | |
Helper::Xaction * | nextRequest () |
bool | trySubmit (const char *buf, HLPCB *callback, void *data) |
If possible, submit request. Otherwise, either kill Squid or return false. More... | |
void | submitRequest (Helper::Xaction *r) |
void | packStatsInto (Packable *p, const char *label=nullptr) const |
Dump some stats about the helper state to a Packable object. More... | |
bool | willOverload () const |
void | handleKilledServer (HelperServerBase *srv, bool &needsNewServers) |
Public Attributes | |
wordlist * | cmdline |
dlink_list | servers |
std::queue< Helper::Xaction * > | queue |
const char * | id_name |
Helper::ChildConfig | childs |
Configuration settings for number running. More... | |
int | ipc_type |
Ip::Address | addr |
unsigned int | droppedRequests |
requests not sent during helper overload More... | |
time_t | overloadStart |
when the helper became overloaded (zero if it is not) More... | |
time_t | last_queue_warn |
time_t | last_restart |
time_t | timeout |
Requests timeout. More... | |
bool | retryTimedOut |
Whether the timed-out requests must retried. More... | |
bool | retryBrokenHelper |
Whether the requests must retried on BH replies. More... | |
SBuf | onTimedOutResponse |
The response to use when helper response timedout. More... | |
char | eom |
The char which marks the end of (response) message, normally ' '. More... | |
struct helper::_stats | stats |
Protected Member Functions | |
bool | queueFull () const |
whether queuing an additional request would overload the helper More... | |
bool | overloaded () const |
void | syncQueueStats () |
synchronizes queue-dependent measurements with the current queue state More... | |
bool | prepSubmit () |
void | submit (const char *buf, HLPCB *callback, void *data) |
dispatches or enqueues a helper requests; does not enforce queue limits More... | |
Static Private Attributes | |
static cbdata_type | CBDATA_helper = CBDATA_UNKNOWN |
Friends | |
void | helperSubmit (helper *hlp, const char *buf, HLPCB *callback, void *data) |
Detailed Description
Managers a set of individual helper processes with a common queue of requests.
With respect to load, a helper goes through these states (roughly): idle: no processes are working on requests (and no requests are queued); normal: some, but not all processes are working (and no requests are queued); busy: all processes are working (and some requests are possibly queued); overloaded: a busy helper with more than queue-size requests in the queue.
A busy helper queues new requests and issues a WARNING every 10 minutes or so. An overloaded helper either drops new requests or keeps queuing them, depending on whether the caller can handle dropped requests (trySubmit vs helperSubmit APIs). If an overloaded helper has been overloaded for 3+ minutes, an attempt to use it results in on-persistent-overload action, which may kill worker.
Constructor & Destructor Documentation
◆ helper()
|
inline |
◆ ~helper()
Definition at line 823 of file helper.cc.
References DBG_CRITICAL, debugs, id_name, queue, helper::_stats::queue_size, and stats.
Member Function Documentation
◆ handleKilledServer()
void helper::handleKilledServer | ( | HelperServerBase * | srv, |
bool & | needsNewServers | ||
) |
Updates interall statistics and start new helper server processes after an unexpected server exit
- Parameters
-
needsNewServers true if new servers must started, false otherwise
Definition at line 833 of file helper.cc.
References assert, childs, DBG_CRITICAL, DBG_IMPORTANT, debugs, fatalf(), HelperServerBase::flags, id_name, HelperServerBase::index, last_restart, Helper::ChildConfig::n_active, Helper::ChildConfig::n_max, Helper::ChildConfig::n_startup, Helper::ChildConfig::needNew(), HelperServerBase::replies, HelperServerBase::_helper_flags::shutdown, squid_curtime, and HelperServerBase::stats.
Referenced by helper_server::HelperServerClosed(), and helper_stateful_server::HelperServerClosed().
◆ nextRequest()
Helper::Xaction * helper::nextRequest | ( | ) |
- Returns
- next request in the queue, or nil.
Definition at line 1261 of file helper.cc.
References queue, helper::_stats::queue_size, and stats.
Referenced by helperKickQueue(), and helperStatefulKickQueue().
◆ operator delete()
◆ operator new()
◆ overloaded()
|
protected |
Definition at line 486 of file helper.cc.
References childs, helper::_stats::queue_size, Helper::ChildConfig::queue_size, and stats.
Referenced by prepSubmit(), and syncQueueStats().
◆ packStatsInto()
void helper::packStatsInto | ( | Packable * | p, |
const char * | label = nullptr |
||
) | const |
Definition at line 677 of file helper.cc.
References HelperServerBase::answer_time, Packable::append(), Packable::appendf(), assert, helper::_stats::avg_svc_time, Helper::Request::buf, childs, HelperServerBase::_helper_flags::closing, cmdline, current_time, HelperServerBase::dispatch_time, Helper::Request::dispatch_time, Comm::Connection::fd, HelperServerBase::flags, dlink_list::head, HelperServerBase::index, int, wordlist::key, Helper::ChildConfig::n_active, Helper::ChildConfig::n_max, Helper::ChildConfig::n_running, dlink_node::next, HelperServerBase::pending, HelperServerBase::pid, Helper::Request::placeholder, PRIu64, helper::_stats::queue_size, Format::QuoteMimeBlob(), HelperServerBase::readPipe, helper::_stats::replies, HelperServerBase::replies, Helper::Xaction::request, helper::_stats::requests, HelperServerBase::requests, HelperServerBase::reserved(), HelperServerBase::roffset, servers, HelperServerBase::_helper_flags::shutdown, stats, HelperServerBase::stats, helper::_stats::timedout, HelperServerBase::timedout, tvSubMsec(), HelperServerBase::uses, InstanceId< Class, ValueType >::value, and HelperServerBase::_helper_flags::writing.
Referenced by authenticateBasicStats(), authenticateDigestStats(), authenticateNegotiateStats(), authenticateNTLMStats(), redirectStats(), and storeIdStats().
◆ prepSubmit()
|
protected |
prepares the helper for request submission returns true if and only if the submission should proceed may kill Squid if the helper remains overloaded for too long
Definition at line 519 of file helper.cc.
References Helper::ChildConfig::actDie, childs, DBG_IMPORTANT, debugs, droppedRequests, fatalf(), id_name, Helper::ChildConfig::onPersistentOverload, overloaded(), overloadStart, squid_curtime, and syncQueueStats().
Referenced by trySubmit(), and statefulhelper::trySubmit().
◆ queueFull()
|
protected |
Definition at line 481 of file helper.cc.
References childs, helper::_stats::queue_size, Helper::ChildConfig::queue_size, and stats.
Referenced by willOverload().
◆ submit()
|
protected |
Definition at line 557 of file helper.cc.
References DBG_DATA, debugs, and submitRequest().
Referenced by trySubmit().
◆ submitRequest()
void helper::submitRequest | ( | Helper::Xaction * | r | ) |
Submits a request to the helper or add it to the queue if none of the servers is available.
Definition at line 446 of file helper.cc.
References Enqueue(), GetFirstAvailable(), helperDispatch(), and syncQueueStats().
Referenced by helper_server::checkForTimedOutRequests(), helperReturnBuffer(), and submit().
◆ syncQueueStats()
|
protected |
Definition at line 492 of file helper.cc.
References DBG_IMPORTANT, debugs, droppedRequests, id_name, overloaded(), overloadStart, and squid_curtime.
Referenced by prepSubmit(), statefulhelper::submit(), and submitRequest().
◆ toCbdata()
◆ trySubmit()
bool helper::trySubmit | ( | const char * | buf, |
HLPCB * | callback, | ||
void * | data | ||
) |
Definition at line 546 of file helper.cc.
References prepSubmit(), and submit().
Referenced by ExternalACLLookup::Start().
◆ willOverload()
bool helper::willOverload | ( | ) | const |
whether the helper will be in "overloaded" state after one more request already overloaded helpers return true
Definition at line 735 of file helper.cc.
References childs, GetFirstAvailable(), Helper::ChildConfig::needNew(), and queueFull().
Referenced by aclMatchExternal(), redirectStart(), and storeIdStart().
Friends And Related Function Documentation
◆ helperSubmit
Member Data Documentation
◆ addr
Ip::Address helper::addr |
Definition at line 113 of file helper.h.
Referenced by helperOpenServers(), and helperStatefulOpenServers().
◆ CBDATA_helper
|
staticprivate |
◆ childs
Helper::ChildConfig helper::childs |
Definition at line 111 of file helper.h.
Referenced by helper_server::~helper_server(), helper_stateful_server::~helper_stateful_server(), helper_server::checkForTimedOutRequests(), Enqueue(), GetFirstAvailable(), handleKilledServer(), helperDispatch(), helperHandleRead(), helperOpenServers(), helperReturnBuffer(), helperShutdown(), helperStatefulOpenServers(), helperStatefulShutdown(), Ssl::Helper::Init(), overloaded(), packStatsInto(), helper_server::popRequest(), prepSubmit(), queueFull(), redirectInit(), StatefulEnqueue(), StatefulGetFirstAvailable(), and willOverload().
◆ cmdline
wordlist* helper::cmdline |
Definition at line 107 of file helper.h.
Referenced by helperOpenServers(), helperStatefulOpenServers(), Ssl::Helper::Init(), packStatsInto(), and redirectInit().
◆ droppedRequests
unsigned int helper::droppedRequests |
Definition at line 114 of file helper.h.
Referenced by prepSubmit(), and syncQueueStats().
◆ eom
char helper::eom |
Definition at line 122 of file helper.h.
Referenced by helperHandleRead(), helperStatefulHandleRead(), and Ssl::Helper::Init().
◆ id_name
const char* helper::id_name |
Definition at line 110 of file helper.h.
Referenced by ~helper(), helper_server::~helper_server(), helper_stateful_server::~helper_stateful_server(), Enqueue(), handleKilledServer(), helperDispatch(), helperDispatchWriteDone(), helperHandleRead(), helperReturnBuffer(), helperShutdown(), helperStatefulDispatch(), helperStatefulHandleRead(), helperStatefulServerDone(), helperStatefulShutdown(), prepSubmit(), StatefulEnqueue(), statefulhelper::submit(), and syncQueueStats().
◆ ipc_type
int helper::ipc_type |
Definition at line 112 of file helper.h.
Referenced by helperOpenServers(), helperStatefulOpenServers(), Ssl::Helper::Init(), and redirectInit().
◆ last_queue_warn
time_t helper::last_queue_warn |
Definition at line 116 of file helper.h.
Referenced by Enqueue(), and StatefulEnqueue().
◆ last_restart
time_t helper::last_restart |
Definition at line 117 of file helper.h.
Referenced by handleKilledServer(), helperOpenServers(), and helperStatefulOpenServers().
◆ onTimedOutResponse
SBuf helper::onTimedOutResponse |
Definition at line 121 of file helper.h.
Referenced by helper_server::checkForTimedOutRequests(), and redirectInit().
◆ overloadStart
time_t helper::overloadStart |
Definition at line 115 of file helper.h.
Referenced by prepSubmit(), and syncQueueStats().
◆ queue
std::queue<Helper::Xaction *> helper::queue |
Definition at line 109 of file helper.h.
Referenced by ~helper(), Enqueue(), nextRequest(), and StatefulEnqueue().
◆ retryBrokenHelper
bool helper::retryBrokenHelper |
Definition at line 120 of file helper.h.
Referenced by redirectInit().
◆ retryTimedOut
bool helper::retryTimedOut |
Definition at line 119 of file helper.h.
Referenced by helperReturnBuffer(), redirectInit(), and helper_server::requestTimeout().
◆ servers
dlink_list helper::servers |
Definition at line 108 of file helper.h.
Referenced by helper_server::~helper_server(), helper_stateful_server::~helper_stateful_server(), GetFirstAvailable(), helperOpenServers(), helperShutdown(), helperStatefulOpenServers(), helperStatefulShutdown(), packStatsInto(), and StatefulGetFirstAvailable().
◆ stats
struct helper::_stats helper::stats |
◆ timeout
time_t helper::timeout |
Definition at line 118 of file helper.h.
Referenced by helper_server::checkForTimedOutRequests(), helperOpenServers(), helperReturnBuffer(), redirectInit(), and helper_server::requestTimeout().
The documentation for this class was generated from the following files:
- src/helper.h
- src/helper.cc
- src/tests/stub_helper.cc