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 
17 class MemBuf;
18 
19 extern int DebugSignal;
20 
23 extern SBuf service_name;
24 
25 void parseEtcHosts(void);
26 int getMyPort(void);
27 void setUmask(mode_t mask);
28 void strwordquote(MemBuf * mb, const char *str);
29 
30 class Packable;
31 
32 /* a common objPackInto interface; used by debugObj */
33 typedef void (*ObjPackMethod) (void *obj, Packable * p);
34 
35 /* packs, then prints an object using debugs() */
36 void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
37 
39 typedef void SIGHDLR(int sig);
40 
41 const char *getMyHostname(void);
42 const char *uniqueHostname(void);
43 
44 void death(int sig);
45 void sigusr2_handle(int sig);
46 void sig_child(int sig);
47 void sig_shutdown(int sig);
48 void leave_suid(void);
49 void enter_suid(void);
50 void no_suid(void);
51 void setMaxFD(void);
52 void setSystemLimits(void);
53 void squid_signal(int sig, SIGHDLR *, int flags);
54 void keepCapabilities(void);
55 void BroadcastSignalIfAny(int& sig);
56 
58 bool IamMasterProcess();
63 bool IamPrimaryProcess();
67 bool IamWorkerProcess();
69 bool IamDiskProcess();
71 bool InDaemonMode(); // try using specific Iam*() checks above first
73 bool UsingSmp(); // try using specific Iam*() checks above first
75 int NumberOfKids();
78 
79 void debug_trap(const char *);
80 
81 void logsFlush(void);
82 
83 void squid_getrusage(struct rusage *r);
84 double rusage_cputime(struct rusage *r);
85 int rusage_maxrss(struct rusage *r);
86 int rusage_pagefaults(struct rusage *r);
87 void releaseServerSockets(void);
88 void PrintRusage(void);
89 void dumpMallocStats(void);
90 
91 typedef int PidStatus;
92 
99 pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags);
100 
107 inline pid_t WaitForAnyPid(PidStatus &status, int flags)
108 {
109  return WaitForOnePid(-1, status, flags);
110 }
111 
112 #if _SQUID_WINDOWS_
113 SBuf WindowsErrorMessage(DWORD errorId);
115 #endif // _SQUID_WINDOWS_
116 
117 #endif /* SQUID_TOOLS_H_ */
118 
void PrintRusage(void)
Definition: tools.cc:326
bool InDaemonMode()
Whether we are running in daemon mode.
Definition: tools.cc:687
void SIGHDLR(int sig)
callback type for signal handlers
Definition: tools.h:39
void setSystemLimits(void)
Definition: tools.cc:808
const char * getMyHostname(void)
Definition: tools.cc:464
int rusage_maxrss(struct rusage *r)
Definition: tools.cc:250
void setMaxFD(void)
Definition: tools.cc:759
void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm)
Definition: tools.cc:935
void squid_getrusage(struct rusage *r)
Definition: tools.cc:177
void setUmask(mode_t mask)
Definition: tools.cc:1066
SBuf service_name
Definition: SBuf.h:94
void debug_trap(const char *)
Definition: tools.cc:455
int getMyPort(void)
Definition: tools.cc:1038
bool IamCoordinatorProcess()
whether the current process coordinates worker processes
Definition: tools.cc:699
double rusage_cputime(struct rusage *r)
Definition: tools.cc:235
void no_suid(void)
Definition: tools.cc:643
void releaseServerSockets(void)
Definition: tools.cc:89
const char * uniqueHostname(void)
Definition: tools.cc:544
static pid_t pid
Definition: IcmpSquid.cc:34
void BroadcastSignalIfAny(int &sig)
Definition: tools.cc:415
void(* ObjPackMethod)(void *obj, Packable *p)
Definition: tools.h:33
void enter_suid(void)
Definition: tools.cc:620
Definition: MemBuf.h:24
void sig_shutdown(int sig)
handles shutdown notifications from kids
void sig_child(int sig)
Definition: main.cc:794
void leave_suid(void)
Definition: tools.cc:556
bool IamPrimaryProcess()
Definition: tools.cc:705
void parseEtcHosts(void)
Definition: tools.cc:946
int DebugSignal
Definition: stub_tools.cc:16
void death(int sig)
Definition: tools.cc:342
pid_t WaitForAnyPid(PidStatus &status, int flags)
Definition: tools.h:107
pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags)
Definition: tools.cc:1177
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:693
void dumpMallocStats(void)
Definition: tools.cc:163
void keepCapabilities(void)
Definition: tools.cc:1119
bool IamMasterProcess()
whether the current process is the parent of all other Squid processes
Definition: tools.cc:665
int PidStatus
Definition: tools.h:91
unsigned short mode_t
Definition: types.h:150
int rusage_pagefaults(struct rusage *r)
Definition: tools.cc:271
int NumberOfKids()
number of Kid processes as defined in src/ipc/Kid.h
Definition: tools.cc:721
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 strwordquote(MemBuf *mb, const char *str)
Definition: tools.cc:1077
void squid_signal(int sig, SIGHDLR *, int flags)
Definition: tools.cc:870
bool IamWorkerProcess()
whether the current process handles HTTP transactions and such
Definition: stub_tools.cc:47
void logsFlush(void)
Definition: tools.cc:928
void sigusr2_handle(int sig)
Definition: tools.cc:430

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors