#include <helper.h>

Inheritance diagram for helper:
Collaboration diagram for helper:

Classes

struct  _stats
 

Public Member Functions

void * operator new (size_t size)
 
void operator delete (void *address)
 
void * toCbdata () noexcept
 
 helper (const char *name)
 
virtual ~helper ()
 
Helper::XactionnextRequest ()
 
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=NULL) const
 Dump some stats about the helper state to a Packable object. More...
 
bool willOverload () const
 
void handleKilledServer (HelperServerBase *srv, bool &needsNewServers)
 

Public Attributes

wordlistcmdline = nullptr
 
dlink_list servers
 
std::queue< Helper::Xaction * > queue
 
const char * id_name = nullptr
 
Helper::ChildConfig childs
 configuration settings for number running More...
 
int ipc_type = 0
 
Ip::Address addr
 
unsigned int droppedRequests = 0
 requests not sent during helper overload More...
 
time_t overloadStart = 0
 when the helper became overloaded (zero if it is not) More...
 
time_t last_queue_warn = 0
 
time_t last_restart = 0
 
time_t timeout = 0
 requests timeout More...
 
bool retryTimedOut = false
 whether the timed-out requests must retried More...
 
bool retryBrokenHelper = false
 whether the requests must retried on BH replies More...
 
SBuf onTimedOutResponse
 the response to use when helper response timedout More...
 
char eom = '\n'
 the char which marks the end of (response) message 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.

Definition at line 65 of file helper.h.

Constructor & Destructor Documentation

◆ helper()

helper::helper ( const char *  name)
inlineexplicit

Definition at line 70 of file helper.h.

◆ ~helper()

void const char HLPCB void helper_stateful_server *lastserver STUB helper::~helper ( )
virtual

Definition at line 808 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 
)

◆ nextRequest()

Helper::Xaction * helper::nextRequest ( )
Returns
next request in the queue, or nil.

Definition at line 1247 of file helper.cc.

References queue, helper::_stats::queue_size, and stats.

Referenced by helperKickQueue(), and helperStatefulKickQueue().

◆ operator delete()

void helper::operator delete ( void *  address)
inline

Definition at line 67 of file helper.h.

◆ operator new()

void* helper::operator new ( size_t  size)
inline

Definition at line 67 of file helper.h.

◆ overloaded()

bool helper::overloaded ( ) const
protected

Definition at line 471 of file helper.cc.

References childs, Helper::ChildConfig::queue_size, helper::_stats::queue_size, and stats.

Referenced by prepSubmit(), and syncQueueStats().

◆ packStatsInto()

◆ prepSubmit()

bool helper::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 504 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()

bool helper::queueFull ( ) const
protected

Definition at line 466 of file helper.cc.

References childs, Helper::ChildConfig::queue_size, helper::_stats::queue_size, and stats.

Referenced by willOverload().

◆ submit()

void helper::submit ( const char *  buf,
HLPCB callback,
void *  data 
)
protected

Definition at line 542 of file helper.cc.

References buf, callback, data, 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 431 of file helper.cc.

References Enqueue(), GetFirstAvailable(), helperDispatch(), and syncQueueStats().

Referenced by helper_server::checkForTimedOutRequests(), helperReturnBuffer(), and submit().

◆ syncQueueStats()

void helper::syncQueueStats ( )
protected

◆ toCbdata()

void* helper::toCbdata ( )
inlinenoexcept

Definition at line 67 of file helper.h.

◆ trySubmit()

bool helper::trySubmit ( const char *  buf,
HLPCB callback,
void *  data 
)

Definition at line 531 of file helper.cc.

References buf, callback, data, prepSubmit(), and submit().

Referenced by helperSubmit(), and 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 720 of file helper.cc.

References childs, GetFirstAvailable(), Helper::ChildConfig::needNew(), and queueFull().

Referenced by aclMatchExternal(), redirectStart(), and storeIdStart().

Friends And Related Function Documentation

◆ helperSubmit

void helperSubmit ( helper hlp,
const char *  buf,
HLPCB callback,
void *  data 
)
friend

Definition at line 458 of file helper.cc.

Member Data Documentation

◆ addr

Ip::Address helper::addr

Definition at line 101 of file helper.h.

Referenced by helperOpenServers(), and helperStatefulOpenServers().

◆ CBDATA_helper

cbdata_type helper::CBDATA_helper = CBDATA_UNKNOWN
staticprivate

Definition at line 67 of file helper.h.

◆ childs

◆ cmdline

wordlist* helper::cmdline = nullptr

◆ droppedRequests

unsigned int helper::droppedRequests = 0

Definition at line 102 of file helper.h.

Referenced by prepSubmit(), and syncQueueStats().

◆ eom

char helper::eom = '\n'

Definition at line 110 of file helper.h.

Referenced by helperHandleRead(), helperStatefulHandleRead(), and Ssl::Helper::Init().

◆ id_name

◆ ipc_type

int helper::ipc_type = 0

◆ last_queue_warn

time_t helper::last_queue_warn = 0

Definition at line 104 of file helper.h.

Referenced by Enqueue(), and StatefulEnqueue().

◆ last_restart

time_t helper::last_restart = 0

Definition at line 105 of file helper.h.

Referenced by handleKilledServer(), helperOpenServers(), and helperStatefulOpenServers().

◆ onTimedOutResponse

SBuf helper::onTimedOutResponse

Definition at line 109 of file helper.h.

Referenced by helper_server::checkForTimedOutRequests(), and redirectInit().

◆ overloadStart

time_t helper::overloadStart = 0

Definition at line 103 of file helper.h.

Referenced by prepSubmit(), and syncQueueStats().

◆ queue

std::queue<Helper::Xaction *> helper::queue

Definition at line 97 of file helper.h.

Referenced by Enqueue(), nextRequest(), StatefulEnqueue(), and ~helper().

◆ retryBrokenHelper

bool helper::retryBrokenHelper = false

Definition at line 108 of file helper.h.

Referenced by redirectInit().

◆ retryTimedOut

bool helper::retryTimedOut = false

Definition at line 107 of file helper.h.

Referenced by helperReturnBuffer(), redirectInit(), and helper_server::requestTimeout().

◆ servers

◆ stats

◆ timeout


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors