|
Squid Web Cache master
|
#include "squid.h"#include "anyp/PortCfg.h"#include "base/Subscription.h"#include "client_side.h"#include "compat/unistd.h"#include "fatal.h"#include "fde.h"#include "fqdncache.h"#include "fs_io.h"#include "htcp.h"#include "http/Stream.h"#include "ICP.h"#include "ip/Intercept.h"#include "ip/QosConfig.h"#include "ipc/Coordinator.h"#include "ipc/Kids.h"#include "ipcache.h"#include "MemBuf.h"#include "sbuf/Stream.h"#include "SquidConfig.h"#include "SquidMath.h"#include "store/Disks.h"#include "tools.h"#include "wordlist.h"#include <cerrno>Go to the source code of this file.
Macros | |
| #define | DEAD_MSG "\The Squid Cache (version %s) died.\n\\n\You've encountered a fatal error in the Squid Cache version %s.\n\If a core file was created (possibly in the swap directory),\n\please execute 'gdb squid core' or 'dbx squid core', then type 'where',\n\and report the trace back to squid-bugs@lists.squid-cache.org.\n\\n\Thanks!\n" |
| #define | HAVE_GETPAGESIZE 0 |
Functions | |
| static void | mail_warranty (void) |
| static void | restoreCapabilities (bool keep) |
| void | releaseServerSockets (void) |
| static char * | dead_msg (void) |
| void | dumpMallocStats (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) |
| static void | makeTraceable () |
| static void | setTraceability () |
| void | PrintRusage (void) |
| void | death (int sig) |
| void | BroadcastSignalIfAny (int &sig) |
| void | sigusr2_handle (int sig) |
| void | debug_trap (const char *message) |
| const char * | getMyHostname (void) |
| const char * | uniqueHostname (void) |
| void | leave_suid (void) |
| void | enter_suid (void) |
| void | no_suid (void) |
| bool | IamMasterProcess () |
| whether the current process is the parent of all other Squid processes | |
| bool | IamWorkerProcess () |
| whether the current process handles HTTP transactions and such | |
| bool | IamDiskProcess () |
| whether the current process is dedicated to managing a cache_dir | |
| bool | InDaemonMode () |
| Whether we are running in daemon mode. | |
| bool | UsingSmp () |
| Whether there should be more than one worker process running. | |
| bool | IamCoordinatorProcess () |
| whether the current process coordinates worker processes | |
| bool | IamPrimaryProcess () |
| int | NumberOfKids () |
| number of Kid processes as defined in src/ipc/Kid.h | |
| SBuf | ProcessRoles () |
| a string describing this process roles such as worker or coordinator | |
| void | setMaxFD (void) |
| void | setSystemLimits (void) |
| void | squid_signal (int sig, SIGHDLR *func, int flags) |
| void | logsFlush (void) |
| void | debugObj (int section, int level, const char *label, void *obj, ObjPackMethod pm) |
| void | parseEtcHosts (void) |
| int | getMyPort (void) |
| void | setUmask (mode_t mask) |
| void | strwordquote (MemBuf *mb, const char *str) |
| void | keepCapabilities (void) |
| pid_t | WaitForOnePid (pid_t pid, PidStatus &status, int flags) |
Variables | |
| int | DebugSignal = -1 |
| SBuf | service_name (APP_SHORTNAME) |
| static char | tmp_error_buf [32768] |
| #define DEAD_MSG "\The Squid Cache (version %s) died.\n\\n\You've encountered a fatal error in the Squid Cache version %s.\n\If a core file was created (possibly in the swap directory),\n\please execute 'gdb squid core' or 'dbx squid core', then type 'where',\n\and report the trace back to squid-bugs@lists.squid-cache.org.\n\\n\Thanks!\n" |
| void BroadcastSignalIfAny | ( | int & | sig | ) |
Definition at line 411 of file tools.cc.
References Kids::count(), Kids::get(), IamMasterProcess(), and TheKids.
Referenced by masterCheckAndBroadcastSignals().
|
static |
Definition at line 108 of file tools.cc.
References DEAD_MSG, LOCAL_ARRAY, and version_string.
Referenced by death(), and mail_warranty().
| void death | ( | int | sig | ) |
Definition at line 338 of file tools.cc.
References SquidConfig::adminEmail, Config, DBG_CRITICAL, dead_msg(), debugs, DebugStream(), dumpMallocStats(), ForceAlert(), mail_warranty(), Debug::PrepareToDie(), PrintRusage(), releaseServerSockets(), shutting_down, squid_curtime, SQUID_RELEASE_TIME, and storeDirWriteCleanLogs().
Referenced by mainInitialize().
| void debug_trap | ( | const char * | message | ) |
Definition at line 451 of file tools.cc.
References DBG_CRITICAL, debugs, fatal_dump(), and opt_catch_signals.
Referenced by EventScheduler::cancel(), clientdbEstablished(), clientdbUpdate(), neighborsUdpAck(), netdbHashDelete(), and unlinkdUnlink().
| void debugObj | ( | int | section, |
| int | level, | ||
| const char * | label, | ||
| void * | obj, | ||
| ObjPackMethod | pm | ||
| ) |
Definition at line 931 of file tools.cc.
References assert, MemBuf::buf, MemBuf::clean(), debugs, and MemBuf::init().
Referenced by clientInterpretRequestHeaders(), and internalStart().
| void dumpMallocStats | ( | void | ) |
Definition at line 167 of file tools.cc.
References DebugStream(), and Math::intPercent().
Referenced by death(), fatal_common(), and SquidShutdown().
| void enter_suid | ( | void | ) |
Definition at line 616 of file tools.cc.
References debugs, setTraceability(), and xstrerr().
Referenced by comm_set_transparent(), htcpOpenPorts(), icpOpenPorts(), mainReconfigureFinish(), File::open(), Ipc::Coordinator::openListenSocket(), Ip::Intercept::ProbeForTproxy(), RemoveInstance(), squid_getrusage(), SquidMain(), Ipc::StartListening(), StartUsingConfig(), and watch_child().
| const char * getMyHostname | ( | void | ) |
Definition at line 460 of file tools.cc.
References Config, DBG_CRITICAL, DBG_IMPORTANT, debugs, Ip::Address::FreeAddr(), Ip::Address::getAddrInfo(), HttpPortList, Ip::Address::isAnyAddr(), LOCAL_ARRAY, SQUIDHOSTNAMELEN, SquidConfig::visibleHostname, xgethostname(), and xstrerr().
Referenced by ErrorState::compileLegacyCode(), configDoConfigure(), ErrorState::Dump(), idnsParseResolvConf(), internalHostname(), internalLocalUri(), neighbors_init(), uniqueHostname(), and urnHandleReply().
| int getMyPort | ( | void | ) |
Definition at line 1034 of file tools.cc.
References DBG_CRITICAL, debugs, FtpPortList, and HttpPortList.
Referenced by ClientHttpRequest::checkForInternalAccess(), ErrorState::compileLegacyCode(), and internalLocalUri().
| bool IamCoordinatorProcess | ( | ) |
Definition at line 695 of file tools.cc.
References pkCoordinator, and TheProcessKind.
Referenced by IamPrimaryProcess(), ProcessRoles(), and SquidMain().
| bool IamDiskProcess | ( | ) |
Definition at line 677 of file tools.cc.
References pkDisker, and TheProcessKind.
Referenced by ProcessRoles().
| bool IamMasterProcess | ( | ) |
Definition at line 661 of file tools.cc.
References KidIdentifier.
Referenced by BroadcastSignalIfAny(), ProcessRoles(), SquidMain(), StartUsingConfig(), and Ipc::Mem::RegisteredRunner::useConfig().
| 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 701 of file tools.cc.
References Config, IamCoordinatorProcess(), IamWorkerProcess(), NumberOfKids(), opt_no_daemon, and SquidConfig::workers.
Referenced by Mgr::InfoAction::dump(), mainReconfigureFinish(), SquidMain(), wccp2ConnectionClose(), wccp2ConnectionOpen(), wccp2Init(), wccpConnectionClose(), wccpConnectionOpen(), and wccpInit().
| bool IamWorkerProcess | ( | ) |
Definition at line 667 of file tools.cc.
References Config, opt_no_daemon, pkWorker, TheProcessKind, and SquidConfig::workers.
Referenced by IamPrimaryProcess(), and ProcessRoles().
| bool InDaemonMode | ( | ) |
Definition at line 683 of file tools.cc.
References Config, opt_no_daemon, and SquidConfig::workers.
Referenced by Store::Disks::configure(), CpuAffinityCheck(), CpuAffinityInit(), Rock::SwapDir::needsDiskStrand(), NumberOfKids(), SquidMain(), StartUsingConfig(), Ipc::Mem::RegisteredRunner::useConfig(), and UsingSmp().
| void leave_suid | ( | void | ) |
leave a privileged section. (Give up any privilegies) Routines that need privilegies can rap themselves in enter_suid() and leave_suid() To give upp all posibilites to gain privilegies use no_suid()
Definition at line 552 of file tools.cc.
References Config, Config2, DBG_CRITICAL, debugs, SquidConfig::effectiveGroup, SquidConfig2::effectiveGroupID, SquidConfig::effectiveUser, SquidConfig2::effectiveUserID, fatalf(), initgroups(), restoreCapabilities(), setTraceability(), and xstrerr().
Referenced by comm_set_transparent(), fatal(), fatal_dump(), htcpOpenPorts(), icpOpenPorts(), no_suid(), File::open(), Ipc::Coordinator::openListenSocket(), Ip::Intercept::ProbeForTproxy(), RemoveInstance(), setEffectiveUser(), squid_getrusage(), SquidMain(), Ipc::StartListening(), StartUsingConfig(), and watch_child().
| void logsFlush | ( | void | ) |
Definition at line 924 of file tools.cc.
References DebugStream().
|
static |
Definition at line 116 of file tools.cc.
References SquidConfig::adminEmail, APP_SHORTNAME, Config, dead_msg(), SquidConfig::EmailFrom, SquidConfig::EmailProgram, NULL, tempnam(), uniqueHostname(), and xfree.
Referenced by death().
|
static |
Make the process traceable if possible. Call setTraceability() instead! Traceable processes may support attachment via ptrace(2) or ktrace(2), debugging sysctls, hwpmc(4), dtrace(1) and core dumping.
Definition at line 281 of file tools.cc.
References debugs, Here, ToSBuf(), and xstrerr().
Referenced by setTraceability().
| void no_suid | ( | void | ) |
Definition at line 639 of file tools.cc.
References DBG_IMPORTANT, debugs, leave_suid(), restoreCapabilities(), setTraceability(), and xstrerr().
Referenced by ipcCreate(), mainInitialize(), and SquidMain().
| int NumberOfKids | ( | ) |
Definition at line 717 of file tools.cc.
References SquidConfig::cacheSwap, Config, InDaemonMode(), Store::DiskConfig::n_strands, and SquidConfig::workers.
Referenced by CpuAffinityCheck(), IamPrimaryProcess(), Kids::init(), and UsingSmp().
| void parseEtcHosts | ( | void | ) |
Definition at line 942 of file tools.cc.
References SquidConfig::appendDomain, Config, DBG_IMPORTANT, debugs, SquidConfig::etcHostsPath, fqdncacheAddEntryFromHosts(), ipcacheAddEntryFromHosts(), O_TEXT, w_space, and xstrerr().
| void PrintRusage | ( | void | ) |
Definition at line 322 of file tools.cc.
References DebugStream(), rusage::ru_stime, rusage::ru_utime, rusage_cputime(), rusage_maxrss(), rusage_pagefaults(), and squid_getrusage().
Referenced by death(), fatal_common(), and SquidShutdown().
| SBuf ProcessRoles | ( | ) |
Definition at line 732 of file tools.cc.
References SBuf::append(), IamCoordinatorProcess(), IamDiskProcess(), IamMasterProcess(), and IamWorkerProcess().
Referenced by mainInitialize().
| void releaseServerSockets | ( | void | ) |
Definition at line 93 of file tools.cc.
References clientConnectionsClose(), and icpClosePorts().
Referenced by death().
|
static |
Definition at line 1125 of file tools.cc.
References Ip::Qos::TheConfig, and USE_LIBNETFILTERCONNTRACK.
Referenced by leave_suid(), and no_suid().
Definition at line 239 of file tools.cc.
References double, rusage::ru_stime, and rusage::ru_utime.
Referenced by GetCountersStats(), GetInfo(), PrintRusage(), snmp_prfSysFn(), and statAvgTick().
Definition at line 254 of file tools.cc.
References rusage::ru_maxrss.
Referenced by GetInfo(), PrintRusage(), and snmp_prfSysFn().
Definition at line 272 of file tools.cc.
References rusage::ru_majflt.
Referenced by GetCountersStats(), GetInfo(), PrintRusage(), snmp_prfSysFn(), and statAvgTick().
| void setMaxFD | ( | void | ) |
Figure out the number of supported filedescriptors
Definition at line 755 of file tools.cc.
References Config, DBG_CRITICAL, debugs, SquidConfig::max_filedescriptors, Squid_MaxFD, and xstrerr().
Referenced by StartUsingConfig().
| void setSystemLimits | ( | void | ) |
Definition at line 804 of file tools.cc.
References Config, DBG_CRITICAL, DBG_IMPORTANT, debugs, fatal_dump(), SquidConfig::max_filedescriptors, Squid_MaxFD, tmp_error_buf, and xstrerr().
Referenced by mainInitialize().
|
static |
Make the process traceable if necessary.
Definition at line 307 of file tools.cc.
References Config, SquidConfig::coredump_dir, CurrentException(), DBG_IMPORTANT, debugs, Debug::Extra(), and makeTraceable().
Referenced by enter_suid(), leave_suid(), and no_suid().
| void setUmask | ( | mode_t | mask | ) |
Definition at line 1062 of file tools.cc.
Referenced by mainReconfigureFinish(), and SquidMain().
| void sigusr2_handle | ( | int | sig | ) |
Definition at line 426 of file tools.cc.
References DBG_CRITICAL, Debug::debugOptions, debugs, DebugSignal, Debug::parseOptions(), sigusr2_handle(), and xstrerr().
Referenced by mainHandleCommandLineOption(), mainInitialize(), sigusr2_handle(), watch_child(), and WIN32_svcHandler().
| void squid_getrusage | ( | struct rusage * | r | ) |
Definition at line 181 of file tools.cc.
References enter_suid(), FALSE, leave_suid(), rusage::ru_majflt, rusage::ru_maxrss, rusage::ru_stime, and rusage::ru_utime.
Referenced by GetCountersStats(), GetInfo(), PrintRusage(), snmp_prfSysFn(), and statAvgTick().
Definition at line 866 of file tools.cc.
References DBG_CRITICAL, debugs, and xstrerr().
Referenced by mainInitialize(), and watch_child().
| void strwordquote | ( | MemBuf * | mb, |
| const char * | str | ||
| ) |
Definition at line 1073 of file tools.cc.
References MemBuf::append().
Referenced by Format::Format::assemble(), and ACLExternal::makeExternalAclKey().
| const char * uniqueHostname | ( | void | ) |
Definition at line 540 of file tools.cc.
References Config, debugs, getMyHostname(), and SquidConfig::uniqueHostname.
Referenced by clientReplyContext::buildReplyHeader(), configDoConfigure(), mail_warranty(), and snmp_confFn().
| bool UsingSmp | ( | ) |
Definition at line 689 of file tools.cc.
References InDaemonMode(), and NumberOfKids().
Referenced by Rock::SwapDir::create(), Rock::SwapDir::doReportStat(), Ipc::Mem::Segment::Enabled(), Transients::EntryLimit(), MemStoreRr::finalizeConfig(), MemStore::getStats(), CollapsedForwarding::Init(), Rock::Rebuild::IsResponsible(), snmpConstructReponse(), SquidMain(), CacheManager::start(), and Ipc::StartListening().
Compatibility wrapper function for waitpid \pid the pid of child process to wait for.
| status | the exit status returned by waitpid |
| flags | WNOHANG or 0 |
Definition at line 1173 of file tools.cc.
References pid.
Referenced by mainStartScript(), and WaitForAnyPid().
| int DebugSignal = -1 |
Definition at line 74 of file tools.cc.
Referenced by sigusr2_handle().
| SBuf service_name(APP_SHORTNAME) | ( | APP_SHORTNAME | ) |
|
static |
Definition at line 90 of file tools.cc.
Referenced by setSystemLimits().