tools.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 #if _SQUID_NEXT_
92 typedef union wait PidStatus;
93 #else
94 typedef int PidStatus;
95 #endif
96 
103 pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags);
104 
111 inline pid_t WaitForAnyPid(PidStatus &status, int flags)
112 {
113  return WaitForOnePid(-1, status, flags);
114 }
115 
116 #if _SQUID_WINDOWS_
117 SBuf WindowsErrorMessage(DWORD errorId);
119 #endif // _SQUID_WINDOWS_
120 
121 #endif /* SQUID_TOOLS_H_ */
122 
int PidStatus
Definition: tools.h:94
void sig_shutdown(int sig)
handles shutdown notifications from kids
const char * getMyHostname(void)
Definition: tools.cc:412
void sig_child(int sig)
Definition: main.cc:799
int DebugSignal
Definition: stub_tools.cc:16
Definition: SBuf.h:86
pid_t WaitForAnyPid(PidStatus &status, int flags)
Definition: tools.h:111
void dumpMallocStats(void)
Definition: tools.cc:156
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:658
void setUmask(mode_t mask)
Definition: tools.cc:1031
void(* ObjPackMethod)(void *obj, Packable *p)
Definition: tools.h:33
int getMyPort(void)
Definition: tools.cc:1003
void debug_trap(const char *)
Definition: tools.cc:403
SBuf ProcessRoles()
a string describing this process roles such as worker or coordinator
Definition: tools.cc:701
char * p
Definition: membanger.c:43
bool IamCoordinatorProcess()
whether the current process coordinates worker processes
Definition: tools.cc:664
pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags)
Definition: tools.cc:1139
void releaseServerSockets(void)
Definition: tools.cc:82
void squid_signal(int sig, SIGHDLR *, int flags)
Definition: tools.cc:835
void SIGHDLR(int sig)
callback type for signal handlers
Definition: tools.h:39
bool InDaemonMode()
Whether we are running in daemon mode.
Definition: tools.cc:652
double rusage_cputime(struct rusage *r)
Definition: tools.cc:228
int rusage_maxrss(struct rusage *r)
Definition: tools.cc:243
int rusage_pagefaults(struct rusage *r)
Definition: tools.cc:264
void sigusr2_handle(int sig)
Definition: tools.cc:378
bool IamMasterProcess()
whether the current process is the parent of all other Squid processes
Definition: tools.cc:630
void PrintRusage(void)
Definition: tools.cc:275
const char * uniqueHostname(void)
Definition: tools.cc:492
void enter_suid(void)
Definition: tools.cc:575
unsigned short mode_t
Definition: types.h:150
void logsFlush(void)
Definition: tools.cc:893
static pid_t pid
Definition: IcmpSquid.cc:35
void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm)
Definition: tools.cc:900
bool IamDiskProcess()
whether the current process is dedicated to managing a cache_dir
Definition: tools.cc:646
void setMaxFD(void)
Definition: tools.cc:724
void no_suid(void)
Definition: tools.cc:601
void death(int sig)
Definition: tools.cc:291
Definition: MemBuf.h:23
SBuf service_name
bool IamPrimaryProcess()
Definition: tools.cc:670
void BroadcastSignalIfAny(int &sig)
Definition: tools.cc:363
void leave_suid(void)
Definition: tools.cc:504
int NumberOfKids()
number of Kid processes as defined in src/ipc/Kid.h
Definition: tools.cc:686
void strwordquote(MemBuf *mb, const char *str)
Definition: tools.cc:1042
void squid_getrusage(struct rusage *r)
Definition: tools.cc:170
void keepCapabilities(void)
Definition: tools.cc:1084
bool IamWorkerProcess()
whether the current process handles HTTP transactions and such
Definition: stub_tools.cc:49
void setSystemLimits(void)
Definition: tools.cc:773
void parseEtcHosts(void)
Definition: tools.cc:911

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors