tools.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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:559
bool IamMasterProcess()
whether the current process is the parent of all other Squid processes
Definition: tools.cc:668
bool InDaemonMode()
Whether we are running in daemon mode.
Definition: tools.cc:690
void strwordquote(MemBuf *mb, const char *str)
Definition: tools.cc:1080
pid_t WaitForOnePid(pid_t pid, PidStatus &status, int flags)
Definition: tools.cc:1180
bool IamWorkerProcess()
whether the current process handles HTTP transactions and such
Definition: stub_tools.cc:47
const char * getMyHostname(void)
Definition: tools.cc:467
void setUmask(mode_t mask)
Definition: tools.cc:1069
void death(int sig)
Definition: tools.cc:345
void keepCapabilities(void)
Definition: tools.cc:1122
void sigusr2_handle(int sig)
Definition: tools.cc:433
void setMaxFD(void)
Definition: tools.cc:762
void SIGHDLR(int sig)
callback type for signal handlers
Definition: tools.h:39
void squid_getrusage(struct rusage *r)
Definition: tools.cc:180
double rusage_cputime(struct rusage *r)
Definition: tools.cc:238
bool IamPrimaryProcess()
Definition: tools.cc:708
void no_suid(void)
Definition: tools.cc:646
int PidStatus
Definition: tools.h:91
void sig_child(int sig)
Definition: main.cc:771
int rusage_maxrss(struct rusage *r)
Definition: tools.cc:253
void PrintRusage(void)
Definition: tools.cc:329
int NumberOfKids()
number of Kid processes as defined in src/ipc/Kid.h
Definition: tools.cc:724
void squid_signal(int sig, SIGHDLR *, int flags)
Definition: tools.cc:873
void enter_suid(void)
Definition: tools.cc:623
void logsFlush(void)
Definition: tools.cc:931
int getMyPort(void)
Definition: tools.cc:1041
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:938
int DebugSignal
Definition: stub_tools.cc:16
void parseEtcHosts(void)
Definition: tools.cc:949
int rusage_pagefaults(struct rusage *r)
Definition: tools.cc:274
void BroadcastSignalIfAny(int &sig)
Definition: tools.cc:418
bool IamCoordinatorProcess()
whether the current process coordinates worker processes
Definition: tools.cc:702
const char * uniqueHostname(void)
Definition: tools.cc:547
void(* ObjPackMethod)(void *obj, Packable *p)
Definition: tools.h:33
void releaseServerSockets(void)
Definition: tools.cc:92
void dumpMallocStats(void)
Definition: tools.cc:166
void debug_trap(const char *)
Definition: tools.cc:458
bool UsingSmp()
Whether there should be more than one worker process running.
Definition: tools.cc:696
SBuf ProcessRoles()
a string describing this process roles such as worker or coordinator
Definition: tools.cc:739
bool IamDiskProcess()
whether the current process is dedicated to managing a cache_dir
Definition: tools.cc:684
void setSystemLimits(void)
Definition: tools.cc:811
pid_t WaitForAnyPid(PidStatus &status, int flags)
Definition: tools.h:107
unsigned short mode_t
Definition: types.h:129

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors