#include <Kid.h>

Collaboration diagram for Kid:

Public Types

enum  { badFailureLimit = 4 }
 keep restarting until the number of bad failures exceed this limit More...
 
enum  { fastFailureTimeLimit = 10 }
 slower start failures are not "frequent enough" to be counted as "bad" More...
 

Public Member Functions

 Kid ()
 
 Kid (const char *role, const int id)
 
void start (pid_t cpid)
 called when this kid got started, records PID More...
 
void stop (PidStatus const exitStatus)
 called when kid terminates, sets exiting status More...
 
bool running () const
 returns true if tracking of kid is stopped More...
 
bool shouldRestart () const
 returns true if master should restart this kid More...
 
pid_t getPid () const
 returns current pid for a running kid and last pid for a stopped kid More...
 
bool hopeless () const
 whether the failures are "repeated and frequent" More...
 
void forgetFailures ()
 forgets all past failures, ensuring that we are not hopeless() More...
 
time_t deathDuration () const
 
bool calledExit () const
 returns true if the process terminated normally More...
 
int exitStatus () const
 returns the exit status of the process More...
 
bool calledExit (int code) const
 whether the process exited with a given exit status code More...
 
bool exitedHappy () const
 whether the process exited with code 0 More...
 
bool signaled () const
 returns true if the kid was terminated by a signal More...
 
int termSignal () const
 returns the number of the signal that caused the kid to terminate More...
 
bool signaled (int sgnl) const
 whether the process was terminated by a given signal More...
 
SBuf processName () const
 returns kid name More...
 
SBuf gist () const
 

Private Member Functions

void reportStopped () const
 describes a recently stopped kid More...
 

Private Attributes

SBuf processRole
 
int processId = 0
 
int badFailures = 0
 number of "repeated frequent" failures More...
 
pid_t pid = -1
 current (for a running kid) or last (for stopped kid) PID More...
 
time_t startTime = 0
 last start time More...
 
time_t stopTime = 0
 last termination time More...
 
bool isRunning = false
 whether the kid is assumed to be alive More...
 
PidStatus status = 0
 exit status of a stopped kid More...
 

Detailed Description

Squid child, including current forked process info and info persistent across restarts

Definition at line 17 of file Kid.h.

Member Enumeration Documentation

anonymous enum
Enumerator
badFailureLimit 

Definition at line 22 of file Kid.h.

anonymous enum
Enumerator
fastFailureTimeLimit 

Definition at line 25 of file Kid.h.

Constructor & Destructor Documentation

Kid::Kid ( )

Definition at line 23 of file Kid.cc.

Kid::Kid ( const char *  role,
const int  id 
)

Definition at line 27 of file Kid.cc.

Member Function Documentation

bool Kid::calledExit ( ) const

Definition at line 122 of file Kid.cc.

References pid, running(), and status.

Referenced by calledExit(), exitedHappy(), and reportStopped().

bool Kid::calledExit ( int  code) const

Definition at line 134 of file Kid.cc.

References calledExit(), code, and exitStatus().

time_t Kid::deathDuration ( ) const
Returns
the time since process termination

Definition at line 180 of file Kid.cc.

References squid_curtime, and stopTime.

bool Kid::exitedHappy ( ) const

Definition at line 140 of file Kid.cc.

References calledExit().

Referenced by shouldRestart().

int Kid::exitStatus ( ) const

Definition at line 128 of file Kid.cc.

References status.

Referenced by calledExit(), and reportStopped().

void Kid::forgetFailures ( )
inline

Definition at line 51 of file Kid.h.

References badFailures.

pid_t Kid::getPid ( ) const

Definition at line 109 of file Kid.cc.

References assert, and pid.

SBuf Kid::gist ( ) const
Returns
kid's role and ID summary; usable as a –kid parameter value

Definition at line 172 of file Kid.cc.

References SBuf::appendf(), processId, and processRole.

Referenced by processName(), reportStopped(), and watch_child().

bool Kid::hopeless ( ) const

Definition at line 116 of file Kid.cc.

References badFailureLimit, and badFailures.

Referenced by reportStopped(), and shouldRestart().

SBuf Kid::processName ( ) const
Returns
kid's role and ID formatted for use as a process name

Definition at line 164 of file Kid.cc.

References SBuf::append(), and gist().

Referenced by watch_child().

void Kid::reportStopped ( ) const
private
bool Kid::running ( ) const

Definition at line 91 of file Kid.cc.

References isRunning.

Referenced by calledExit(), shouldRestart(), signaled(), start(), and stop().

bool Kid::shouldRestart ( ) const

returns true if master process should restart this kid

Definition at line 97 of file Kid.cc.

References exitedHappy(), hopeless(), running(), shutting_down, and signaled().

Referenced by watch_child().

bool Kid::signaled ( ) const

Definition at line 146 of file Kid.cc.

References pid, running(), and status.

Referenced by reportStopped(), shouldRestart(), and signaled().

bool Kid::signaled ( int  sgnl) const

Definition at line 158 of file Kid.cc.

References signaled(), and termSignal().

void Kid::start ( pid_t  cpid)

Definition at line 34 of file Kid.cc.

References assert, isRunning, pid, running(), squid_curtime, startTime, and stopTime.

Referenced by watch_child().

void Kid::stop ( PidStatus const  exitStatus)
int Kid::termSignal ( ) const

Definition at line 152 of file Kid.cc.

References status.

Referenced by reportStopped(), and signaled().

Member Data Documentation

int Kid::badFailures = 0
private

Definition at line 89 of file Kid.h.

Referenced by forgetFailures(), hopeless(), and stop().

bool Kid::isRunning = false
private

Definition at line 95 of file Kid.h.

Referenced by running(), start(), and stop().

pid_t Kid::pid = -1
private

Definition at line 92 of file Kid.h.

Referenced by calledExit(), getPid(), reportStopped(), signaled(), and start().

int Kid::processId = 0
private

Definition at line 88 of file Kid.h.

Referenced by gist().

SBuf Kid::processRole
private

Definition at line 87 of file Kid.h.

Referenced by gist().

time_t Kid::startTime = 0
private

Definition at line 93 of file Kid.h.

Referenced by start(), and stop().

PidStatus Kid::status = 0
private

Definition at line 96 of file Kid.h.

Referenced by calledExit(), exitStatus(), signaled(), stop(), and termSignal().

time_t Kid::stopTime = 0
private

Definition at line 94 of file Kid.h.

Referenced by deathDuration(), start(), and stop().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors