tools.h File Reference
#include "sbuf/SBuf.h"
#include "typedefs.h"
Include dependency graph for tools.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* ObjPackMethod) (void *obj, Packable *p)
 
typedef void SIGHDLR(int sig)
 callback type for signal handlers More...
 
typedef int PidStatus
 

Functions

void parseEtcHosts (void)
 
int getMyPort (void)
 
void setUmask (mode_t mask)
 
void strwordquote (MemBuf *mb, const char *str)
 
void debugObj (int section, int level, const char *label, void *obj, ObjPackMethod pm)
 
const char * getMyHostname (void)
 
const char * uniqueHostname (void)
 
void death (int sig)
 
void sigusr2_handle (int sig)
 
void sig_child (int sig)
 
void sig_shutdown (int sig)
 handles shutdown notifications from kids More...
 
void leave_suid (void)
 
void enter_suid (void)
 
void no_suid (void)
 
void setMaxFD (void)
 
void setSystemLimits (void)
 
void squid_signal (int sig, SIGHDLR *, int flags)
 
void keepCapabilities (void)
 
void BroadcastSignalIfAny (int &sig)
 
bool IamMasterProcess ()
 whether the current process is the parent of all other Squid processes More...
 
bool IamPrimaryProcess ()
 
bool IamCoordinatorProcess ()
 whether the current process coordinates worker processes More...
 
bool IamWorkerProcess ()
 whether the current process handles HTTP transactions and such More...
 
bool IamDiskProcess ()
 whether the current process is dedicated to managing a cache_dir More...
 
bool InDaemonMode ()
 Whether we are running in daemon mode. More...
 
bool UsingSmp ()
 Whether there should be more than one worker process running. More...
 
int NumberOfKids ()
 number of Kid processes as defined in src/ipc/Kid.h More...
 
SBuf ProcessRoles ()
 a string describing this process roles such as worker or coordinator More...
 
void debug_trap (const char *)
 
void logsFlush (void)
 
void squid_getrusage (struct rusage *r)
 
double rusage_cputime (struct rusage *r)
 
int rusage_maxrss (struct rusage *r)
 
int rusage_pagefaults (struct rusage *r)
 
void releaseServerSockets (void)
 
void PrintRusage (void)
 
void dumpMallocStats (void)
 
pid_t WaitForOnePid (pid_t pid, PidStatus &status, int flags)
 
pid_t WaitForAnyPid (PidStatus &status, int flags)
 

Variables

int DebugSignal
 
SBuf service_name
 

Typedef Documentation

◆ ObjPackMethod

typedef void(* ObjPackMethod) (void *obj, Packable *p)

Definition at line 33 of file tools.h.

◆ PidStatus

typedef int PidStatus

Definition at line 91 of file tools.h.

◆ SIGHDLR

typedef void SIGHDLR(int sig)

Definition at line 39 of file tools.h.

Function Documentation

◆ BroadcastSignalIfAny()

void BroadcastSignalIfAny ( int sig)

Definition at line 418 of file tools.cc.

References Kids::count(), Kids::get(), IamMasterProcess(), and TheKids.

Referenced by masterCheckAndBroadcastSignals().

◆ death()

◆ debug_trap()

void debug_trap ( const char *  message)

◆ debugObj()

void debugObj ( int  section,
int  level,
const char *  label,
void *  obj,
ObjPackMethod  pm 
)

Definition at line 938 of file tools.cc.

References assert, MemBuf::buf, MemBuf::clean(), debugs, and MemBuf::init().

Referenced by clientInterpretRequestHeaders(), and internalStart().

◆ dumpMallocStats()

void dumpMallocStats ( void  )

Definition at line 166 of file tools.cc.

References debug_log, and Math::intPercent().

Referenced by death(), fatal_common(), and SquidShutdown().

◆ enter_suid()

◆ getMyHostname()

◆ getMyPort()

int getMyPort ( void  )

◆ IamCoordinatorProcess()

bool IamCoordinatorProcess ( )

Definition at line 702 of file tools.cc.

References pkCoordinator, and TheProcessKind.

Referenced by IamPrimaryProcess(), ProcessRoles(), and SquidMain().

◆ IamDiskProcess()

◆ IamMasterProcess()

bool IamMasterProcess ( )

◆ IamPrimaryProcess()

bool IamPrimaryProcess ( )

whether the current process is dedicated to doing things that only a single process should do, such as PID file maintenance and WCCP

Definition at line 708 of file tools.cc.

References Config, IamCoordinatorProcess(), IamWorkerProcess(), NumberOfKids(), opt_no_daemon, and SquidConfig::workers.

Referenced by Mgr::InfoAction::dump(), mainInitialize(), mainReconfigureFinish(), serverConnectionsClose(), serverConnectionsOpen(), and SquidMain().

◆ IamWorkerProcess()

◆ InDaemonMode()

◆ keepCapabilities()

void keepCapabilities ( void  )

Definition at line 1122 of file tools.cc.

References Ip::Interceptor.

Referenced by setEffectiveUser().

◆ leave_suid()

◆ logsFlush()

void logsFlush ( void  )

Definition at line 931 of file tools.cc.

References debug_log.

Referenced by ipcCreate().

◆ no_suid()

void no_suid ( void  )

◆ NumberOfKids()

◆ parseEtcHosts()

◆ PrintRusage()

void PrintRusage ( void  )

◆ ProcessRoles()

SBuf ProcessRoles ( )

◆ releaseServerSockets()

void releaseServerSockets ( void  )

Definition at line 92 of file tools.cc.

References clientConnectionsClose(), and icpClosePorts().

Referenced by death().

◆ rusage_cputime()

double rusage_cputime ( struct rusage r)

Definition at line 238 of file tools.cc.

References double, rusage::ru_stime, and rusage::ru_utime.

Referenced by GetCountersStats(), GetInfo(), PrintRusage(), snmp_prfSysFn(), and statAvgTick().

◆ rusage_maxrss()

int rusage_maxrss ( struct rusage r)

Definition at line 253 of file tools.cc.

References rusage::ru_maxrss.

Referenced by GetInfo(), PrintRusage(), and snmp_prfSysFn().

◆ rusage_pagefaults()

int rusage_pagefaults ( struct rusage r)

Definition at line 274 of file tools.cc.

References rusage::ru_majflt.

Referenced by GetCountersStats(), GetInfo(), PrintRusage(), snmp_prfSysFn(), and statAvgTick().

◆ setMaxFD()

void setMaxFD ( void  )

Figure out the number of supported filedescriptors

Definition at line 762 of file tools.cc.

References Config, DBG_CRITICAL, debugs, SquidConfig::max_filedescriptors, Squid_MaxFD, and xstrerr().

Referenced by StartUsingConfig().

◆ setSystemLimits()

void setSystemLimits ( void  )

◆ setUmask()

void setUmask ( mode_t  mask)

Definition at line 1069 of file tools.cc.

Referenced by mainReconfigureFinish(), and SquidMain().

◆ sig_child()

void sig_child ( int  sig)

Definition at line 771 of file main.cc.

References do_handle_stopped_child, and sig_child().

Referenced by mainInitialize(), and sig_child().

◆ sig_shutdown()

void sig_shutdown ( int  sig)

◆ sigusr2_handle()

◆ squid_getrusage()

void squid_getrusage ( struct rusage r)

◆ squid_signal()

void squid_signal ( int  sig,
SIGHDLR func,
int  flags 
)

Definition at line 873 of file tools.cc.

References DBG_CRITICAL, debugs, and xstrerr().

Referenced by mainInitialize(), and watch_child().

◆ strwordquote()

void strwordquote ( MemBuf mb,
const char *  str 
)

Definition at line 1080 of file tools.cc.

References MemBuf::append().

Referenced by Format::Format::assemble(), and makeExternalAclKey().

◆ uniqueHostname()

const char * uniqueHostname ( void  )

◆ UsingSmp()

◆ WaitForAnyPid()

pid_t WaitForAnyPid ( PidStatus status,
int  flags 
)
inline

Wait for state changes in any of the kid processes. Equivalent to waitpid(-1, ...) system call

Parameters
statusthe exit status returned by waitpid
flagsWNOHANG or 0

Definition at line 107 of file tools.h.

References WaitForOnePid().

Referenced by Store::Controller::create(), SignalEngine::handleStoppedChild(), and watch_child().

◆ WaitForOnePid()

pid_t WaitForOnePid ( pid_t  pid,
PidStatus status,
int  flags 
)

Compatibility wrapper function for waitpid \pid the pid of child process to wait for.

Parameters
statusthe exit status returned by waitpid
flagsWNOHANG or 0

Definition at line 1180 of file tools.cc.

References pid.

Referenced by mainStartScript(), and WaitForAnyPid().

Variable Documentation

◆ DebugSignal

int DebugSignal
extern

Definition at line 16 of file stub_tools.cc.

Referenced by masterCheckAndBroadcastSignals(), masterSignaled(), and sigusr2_handle().

◆ service_name

SBuf service_name
extern

The Squid -n parameter service name. Default is APP_SHORTNAME ('squid').

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors