tools.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9/* DEBUG: section 21 Misc Functions */
10
11#ifndef SQUID_TOOLS_H_
12#define SQUID_TOOLS_H_
13
14#include "sbuf/SBuf.h"
15#include "typedefs.h"
16
17class MemBuf;
18
19extern int DebugSignal;
20
23extern SBuf service_name;
24
25void parseEtcHosts(void);
26int getMyPort(void);
27void setUmask(mode_t mask);
28void strwordquote(MemBuf * mb, const char *str);
29
30class Packable;
31
32/* a common objPackInto interface; used by debugObj */
33typedef void (*ObjPackMethod) (void *obj, Packable * p);
34
35/* packs, then prints an object using debugs() */
36void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
37
39typedef void SIGHDLR(int sig);
40
41const char *getMyHostname(void);
42const char *uniqueHostname(void);
43
44void death(int sig);
45void sigusr2_handle(int sig);
46void sig_child(int sig);
47void sig_shutdown(int sig);
48void leave_suid(void);
49void enter_suid(void);
50void no_suid(void);
51void setMaxFD(void);
52void setSystemLimits(void);
53void squid_signal(int sig, SIGHDLR *, int flags);
54void keepCapabilities(void);
55void BroadcastSignalIfAny(int& sig);
56
58bool IamMasterProcess();
67bool IamWorkerProcess();
69bool IamDiskProcess();
71bool InDaemonMode(); // try using specific Iam*() checks above first
73bool UsingSmp(); // try using specific Iam*() checks above first
75int NumberOfKids();
78
79void debug_trap(const char *);
80
81void logsFlush(void);
82
83void squid_getrusage(struct rusage *r);
84double rusage_cputime(struct rusage *r);
85int rusage_maxrss(struct rusage *r);
86int rusage_pagefaults(struct rusage *r);
87void releaseServerSockets(void);
88void PrintRusage(void);
89void dumpMallocStats(void);
90
91typedef int PidStatus;
92
99pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags);
100
107inline pid_t WaitForAnyPid(PidStatus &status, int flags)
108{
109 return WaitForOnePid(-1, status, flags);
110}
111
112#if _SQUID_WINDOWS_
114SBuf WindowsErrorMessage(DWORD errorId);
115#endif // _SQUID_WINDOWS_
116
117#endif /* SQUID_TOOLS_H_ */
118
static pid_t pid
Definition: IcmpSquid.cc:34
Definition: MemBuf.h:24
Definition: SBuf.h:94
void leave_suid(void)
Definition: tools.cc:556
bool IamMasterProcess()
whether the current process is the parent of all other Squid processes
Definition: tools.cc:665
bool InDaemonMode()
Whether we are running in daemon mode.
Definition: tools.cc:687
void strwordquote(MemBuf *mb, const char *str)
Definition: tools.cc:1077
pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags)
Definition: tools.cc:1177
bool IamWorkerProcess()
whether the current process handles HTTP transactions and such
Definition: stub_tools.cc:47
const char * getMyHostname(void)
Definition: tools.cc:464
void setUmask(mode_t mask)
Definition: tools.cc:1066
void death(int sig)
Definition: tools.cc:342
void keepCapabilities(void)
Definition: tools.cc:1119
void sigusr2_handle(int sig)
Definition: tools.cc:430
void setMaxFD(void)
Definition: tools.cc:759
void SIGHDLR(int sig)
callback type for signal handlers
Definition: tools.h:39
void squid_getrusage(struct rusage *r)
Definition: tools.cc:177
double rusage_cputime(struct rusage *r)
Definition: tools.cc:235
bool IamPrimaryProcess()
Definition: tools.cc:705
void no_suid(void)
Definition: tools.cc:643
int PidStatus
Definition: tools.h:91
void sig_child(int sig)
Definition: main.cc:795
int rusage_maxrss(struct rusage *r)
Definition: tools.cc:250
void PrintRusage(void)
Definition: tools.cc:326
int NumberOfKids()
number of Kid processes as defined in src/ipc/Kid.h
Definition: tools.cc:721
void squid_signal(int sig, SIGHDLR *, int flags)
Definition: tools.cc:870
void enter_suid(void)
Definition: tools.cc:620
void logsFlush(void)
Definition: tools.cc:928
int getMyPort(void)
Definition: tools.cc:1038
SBuf service_name
void sig_shutdown(int sig)
handles shutdown notifications from kids
void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm)
Definition: tools.cc:935
int DebugSignal
Definition: stub_tools.cc:16
void parseEtcHosts(void)
Definition: tools.cc:946
int rusage_pagefaults(struct rusage *r)
Definition: tools.cc:271
void BroadcastSignalIfAny(int &sig)
Definition: tools.cc:415
bool IamCoordinatorProcess()
whether the current process coordinates worker processes
Definition: tools.cc:699
const char * uniqueHostname(void)
Definition: tools.cc:544
void(* ObjPackMethod)(void *obj, Packable *p)
Definition: tools.h:33
void releaseServerSockets(void)
Definition: tools.cc:89
void dumpMallocStats(void)
Definition: tools.cc:163
void debug_trap(const char *)
Definition: tools.cc:455
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:693
SBuf ProcessRoles()
a string describing this process roles such as worker or coordinator
Definition: tools.cc:736
bool IamDiskProcess()
whether the current process is dedicated to managing a cache_dir
Definition: tools.cc:681
void setSystemLimits(void)
Definition: tools.cc:808
pid_t WaitForAnyPid(PidStatus &status, int flags)
Definition: tools.h:107
unsigned short mode_t
Definition: types.h:150

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors