#include <helper.h>

Inheritance diagram for Helper::Client:
Collaboration diagram for Helper::Client:

Classes

struct  _stats
 

Public Types

using Pointer = RefCount< Client >
 

Public Member Functions

virtual ~Client ()
 
XactionnextRequest ()
 
bool trySubmit (const char *buf, HLPCB *callback, void *data)
 If possible, submit request. Otherwise, either kill Squid or return false. More...
 
void submitRequest (Xaction *)
 
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 (SessionBase *, bool &needsNewServers)
 
void handleFewerServers (bool madeProgress)
 
void callBack (Xaction &)
 sends transaction response to the transaction initiator More...
 
virtual void openSessions ()
 
void sessionClosed (SessionBase &)
 handles exited helper process More...
 

Static Public Member Functions

static Pointer Make (const char *name)
 

Public Attributes

wordlistcmdline = nullptr
 
dlink_list servers
 
std::queue< Xaction * > queue
 
const char * id_name = nullptr
 
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, normally '
'. More...
 
struct Helper::Client::_stats stats
 

Protected Member Functions

 Client (const char *const name)
 
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...
 

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 66 of file helper.h.

Member Typedef Documentation

◆ Pointer

Definition at line 69 of file helper.h.

Constructor & Destructor Documentation

◆ ~Client()

Client::~Client ( )
virtual

Definition at line 853 of file helper.cc.

References DBG_CRITICAL, debugs, and Ping::stats.

◆ Client()

Helper::Client::Client ( const char *const  name)
inlineexplicitprotected
Parameters
nameadmin-visible helper category (with this process lifetime)

Definition at line 141 of file helper.h.

Member Function Documentation

◆ callBack()

◆ handleFewerServers()

void Client::handleFewerServers ( bool  madeProgress)

Reacts to unexpected helper process death(s), including a failure to start helper(s) and an unexpected exit of a previously started helper.

See also
handleKilledServer()
Parameters
madeProgresswhether the died helper(s) responded to any requests

Definition at line 881 of file helper.cc.

References DBG_CRITICAL, DBG_IMPORTANT, debugs, Debug::Extra(), fatalf(), and squid_curtime.

◆ handleKilledServer()

void Client::handleKilledServer ( SessionBase srv,
bool &  needsNewServers 
)

Updates internal statistics and starts new helper processes after an unexpected server exit

Parameters
needsNewServerstrue if new helper(s) must be started, false otherwise

Definition at line 863 of file helper.cc.

References assert, DBG_CRITICAL, debugs, Helper::SessionBase::flags, Helper::SessionBase::index, Helper::SessionBase::replies, Helper::SessionBase::_helper_flags::shutdown, and Helper::SessionBase::stats.

◆ Make()

Helper::Client::Pointer Client::Make ( const char *  name)
static
Returns
a newly created instance of the named helper client
Parameters
nameadmin-visible helper category (with this process lifetime)

Definition at line 759 of file helper.cc.

Referenced by externalAclInit(), Ssl::Helper::Init(), Ssl::CertValidationHelper::Init(), and redirectInit().

◆ nextRequest()

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

Definition at line 1295 of file helper.cc.

References Ping::stats.

Referenced by helperKickQueue(), and helperStatefulKickQueue().

◆ openSessions()

◆ overloaded()

bool Client::overloaded ( ) const
protected

Definition at line 493 of file helper.cc.

References Ping::stats.

◆ packStatsInto()

void Client::packStatsInto ( Packable p,
const char *  label = nullptr 
) const

◆ prepSubmit()

bool Client::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 526 of file helper.cc.

References Helper::ChildConfig::actDie, DBG_IMPORTANT, debugs, fatalf(), and squid_curtime.

◆ queueFull()

bool Client::queueFull ( ) const
protected

Definition at line 488 of file helper.cc.

References Ping::stats.

◆ sessionClosed()

void Client::sessionClosed ( SessionBase session)

◆ submit()

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

Definition at line 564 of file helper.cc.

References DBG_DATA, and debugs.

◆ submitRequest()

void Client::submitRequest ( Xaction r)

Submits a request to the helper or add it to the queue if none of the servers is available.

Definition at line 455 of file helper.cc.

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

Referenced by helperReturnBuffer().

◆ syncQueueStats()

void Client::syncQueueStats ( )
protected

Definition at line 499 of file helper.cc.

References DBG_IMPORTANT, debugs, and squid_curtime.

◆ trySubmit()

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

Definition at line 553 of file helper.cc.

Referenced by helperSubmit().

◆ willOverload()

bool Client::willOverload ( ) const

whether the helper will be in "overloaded" state after one more request already overloaded helpers return true

Definition at line 754 of file helper.cc.

References GetFirstAvailable().

Member Data Documentation

◆ addr

Ip::Address Helper::Client::addr

Definition at line 120 of file helper.h.

◆ childs

◆ cmdline

wordlist* Helper::Client::cmdline = nullptr

Definition at line 114 of file helper.h.

◆ droppedRequests

unsigned int Helper::Client::droppedRequests = 0

Definition at line 121 of file helper.h.

◆ eom

char Helper::Client::eom = '\n'

Definition at line 129 of file helper.h.

◆ id_name

const char* Helper::Client::id_name = nullptr

◆ ipc_type

int Helper::Client::ipc_type = 0

Definition at line 119 of file helper.h.

◆ last_queue_warn

time_t Helper::Client::last_queue_warn = 0

Definition at line 123 of file helper.h.

Referenced by Enqueue(), and StatefulEnqueue().

◆ last_restart

time_t Helper::Client::last_restart = 0

Definition at line 124 of file helper.h.

◆ onTimedOutResponse

SBuf Helper::Client::onTimedOutResponse

Definition at line 128 of file helper.h.

◆ overloadStart

time_t Helper::Client::overloadStart = 0

Definition at line 122 of file helper.h.

◆ queue

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

Definition at line 116 of file helper.h.

Referenced by Enqueue(), and StatefulEnqueue().

◆ retryBrokenHelper

bool Helper::Client::retryBrokenHelper = false

Definition at line 127 of file helper.h.

◆ retryTimedOut

bool Helper::Client::retryTimedOut = false

Definition at line 126 of file helper.h.

Referenced by helperReturnBuffer().

◆ servers

dlink_list Helper::Client::servers

◆ stats

struct Helper::Client::_stats Helper::Client::stats

◆ timeout

time_t Helper::Client::timeout = 0

Definition at line 125 of file helper.h.

Referenced by helperReturnBuffer().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors