#include <helper.h>

Inheritance diagram for statefulhelper:
Collaboration diagram for statefulhelper:

Public Types

using Pointer = RefCount< statefulhelper >
 
typedef std::unordered_map< Helper::ReservationId, helper_stateful_server * > Reservations
 

Public Member Functions

 ~statefulhelper () override=default
 
void reserveServer (helper_stateful_server *srv)
 reserve the given server More...
 
void cancelReservation (const Helper::ReservationId reservation)
 undo reserveServer(), clear the reservation and kick the queue More...
 
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 (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)
 

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

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...
 

Private Member Functions

 statefulhelper (const char *const name)
 
helper_stateful_serverfindServer (const Helper::ReservationId &reservation)
 
void submit (const char *buf, HLPCB *callback, void *data, const Helper::ReservationId &reservation)
 
bool trySubmit (const char *buf, HLPCB *callback, void *data, const Helper::ReservationId &reservation)
 reserved servers indexed by reservation IDs More...
 

Private Attributes

Reservations reservations
 

Friends

void helperStatefulSubmit (const statefulhelper::Pointer &, const char *buf, HLPCB *, void *cbData, const Helper::ReservationId &)
 

Detailed Description

Definition at line 143 of file helper.h.

Member Typedef Documentation

◆ Pointer

Definition at line 146 of file helper.h.

◆ Reservations

Definition at line 147 of file helper.h.

Constructor & Destructor Documentation

◆ ~statefulhelper()

statefulhelper::~statefulhelper ( )
overridedefault

◆ statefulhelper()

statefulhelper::statefulhelper ( const char *const  name)
inlineexplicitprivate

Definition at line 162 of file helper.h.

Member Function Documentation

◆ cancelReservation()

void statefulhelper::cancelReservation ( const Helper::ReservationId  reservation)

◆ findServer()

helper_stateful_server * statefulhelper::findServer ( const Helper::ReservationId reservation)
private
Returns
the previously reserved server (if the reservation is still valid) or nil

Definition at line 626 of file helper.cc.

◆ handleFewerServers()

void Client::handleFewerServers ( bool  madeProgress)
inherited

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 874 of file helper.cc.

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

Referenced by helperOpenServers(), and helperStatefulOpenServers().

◆ handleKilledServer()

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

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 856 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.

Referenced by helper_stateful_server::HelperServerClosed(), and Helper::Session::HelperServerClosed().

◆ Make()

statefulhelper::Pointer statefulhelper::Make ( const char *  name)
static

Definition at line 758 of file helper.cc.

◆ nextRequest()

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

Definition at line 1297 of file helper.cc.

References Ping::stats.

Referenced by helperKickQueue(), and helperStatefulKickQueue().

◆ overloaded()

bool Client::overloaded ( ) const
protectedinherited

Definition at line 498 of file helper.cc.

References Ping::stats.

◆ packStatsInto()

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

◆ prepSubmit()

bool Client::prepSubmit ( )
protectedinherited

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 531 of file helper.cc.

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

◆ queueFull()

bool Client::queueFull ( ) const
protectedinherited

Definition at line 493 of file helper.cc.

References Ping::stats.

◆ reserveServer()

◆ submit() [1/2]

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

Definition at line 569 of file helper.cc.

References DBG_DATA, and debugs.

◆ submit() [2/2]

◆ submitRequest()

void Client::submitRequest ( Xaction r)
inherited

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

Definition at line 460 of file helper.cc.

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

Referenced by helperReturnBuffer().

◆ syncQueueStats()

void Client::syncQueueStats ( )
protectedinherited

Definition at line 504 of file helper.cc.

References DBG_IMPORTANT, debugs, and squid_curtime.

◆ trySubmit() [1/2]

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

Definition at line 558 of file helper.cc.

Referenced by helperSubmit().

◆ trySubmit() [2/2]

bool statefulhelper::trySubmit ( const char *  buf,
HLPCB callback,
void *  data,
const Helper::ReservationId reservation 
)
private

If possible, submit request. Otherwise, either kill Squid or return false.

Definition at line 587 of file helper.cc.

◆ willOverload()

bool Client::willOverload ( ) const
inherited

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

Definition at line 747 of file helper.cc.

References GetFirstAvailable().

Friends And Related Function Documentation

◆ helperStatefulSubmit

void helperStatefulSubmit ( const statefulhelper::Pointer hlp,
const char *  buf,
HLPCB callback,
void *  cbData,
const Helper::ReservationId reservation 
)
friend

Submit request or callback the caller with a Helper::Error error. If the reservation is not set then reserves a new helper.

Definition at line 579 of file helper.cc.

Member Data Documentation

◆ addr

Ip::Address Helper::Client::addr
inherited

Definition at line 110 of file helper.h.

Referenced by helperOpenServers(), and helperStatefulOpenServers().

◆ childs

◆ cmdline

wordlist* Helper::Client::cmdline = nullptr
inherited

Definition at line 104 of file helper.h.

Referenced by helperOpenServers(), and helperStatefulOpenServers().

◆ droppedRequests

unsigned int Helper::Client::droppedRequests = 0
inherited

Definition at line 111 of file helper.h.

◆ eom

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

Definition at line 119 of file helper.h.

◆ id_name

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

◆ ipc_type

int Helper::Client::ipc_type = 0
inherited

Definition at line 109 of file helper.h.

Referenced by helperOpenServers(), and helperStatefulOpenServers().

◆ last_queue_warn

time_t Helper::Client::last_queue_warn = 0
inherited

Definition at line 113 of file helper.h.

Referenced by Enqueue(), and StatefulEnqueue().

◆ last_restart

time_t Helper::Client::last_restart = 0
inherited

Definition at line 114 of file helper.h.

Referenced by helperOpenServers(), and helperStatefulOpenServers().

◆ onTimedOutResponse

SBuf Helper::Client::onTimedOutResponse
inherited

Definition at line 118 of file helper.h.

◆ overloadStart

time_t Helper::Client::overloadStart = 0
inherited

Definition at line 112 of file helper.h.

◆ queue

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

Definition at line 106 of file helper.h.

Referenced by Enqueue(), and StatefulEnqueue().

◆ reservations

Reservations statefulhelper::reservations
private

Definition at line 171 of file helper.h.

◆ retryBrokenHelper

bool Helper::Client::retryBrokenHelper = false
inherited

Definition at line 117 of file helper.h.

◆ retryTimedOut

bool Helper::Client::retryTimedOut = false
inherited

Definition at line 116 of file helper.h.

Referenced by helperReturnBuffer().

◆ servers

◆ stats

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

◆ timeout

time_t Helper::Client::timeout = 0
inherited

Definition at line 115 of file helper.h.

Referenced by helperOpenServers(), and helperReturnBuffer().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors