]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tools.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / tools.h
1 /*
2 * Copyright (C) 1996-2015 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 "Packer.h"
15 #include "SBuf.h"
16 #include "SquidString.h"
17 #include "typedefs.h"
18
19 class MemBuf;
20
21 extern int DebugSignal;
22
23 /// The Squid -n parameter service name.
24 /// Default is APP_SHORTNAME ('squid').
25 extern SBuf service_name;
26
27 void kb_incr(kb_t *, size_t);
28 void parseEtcHosts(void);
29 int getMyPort(void);
30 void setUmask(mode_t mask);
31 void strwordquote(MemBuf * mb, const char *str);
32
33 /* packs, then prints an object using debugs() */
34 void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
35
36 const char *getMyHostname(void);
37 const char *uniqueHostname(void);
38
39 void death(int sig);
40 void sigusr2_handle(int sig);
41 void sig_child(int sig);
42 void sig_shutdown(int sig); ///< handles shutdown notifications from kids
43 void leave_suid(void);
44 void enter_suid(void);
45 void no_suid(void);
46 void writePidFile(void);
47 void setMaxFD(void);
48 void setSystemLimits(void);
49 void squid_signal(int sig, SIGHDLR *, int flags);
50 pid_t readPidFile(void);
51 void keepCapabilities(void);
52 void BroadcastSignalIfAny(int& sig);
53
54 /// whether the current process is the parent of all other Squid processes
55 bool IamMasterProcess();
56 /**
57 * whether the current process is dedicated to doing things that only
58 * a single process should do, such as PID file maintenance and WCCP
59 */
60 bool IamPrimaryProcess();
61 /// whether the current process coordinates worker processes
62 bool IamCoordinatorProcess();
63 /// whether the current process handles HTTP transactions and such
64 bool IamWorkerProcess();
65 /// whether the current process is dedicated to managing a cache_dir
66 bool IamDiskProcess();
67 /// Whether we are running in daemon mode
68 bool InDaemonMode(); // try using specific Iam*() checks above first
69 /// Whether there should be more than one worker process running
70 bool UsingSmp(); // try using specific Iam*() checks above first
71 /// number of Kid processes as defined in src/ipc/Kid.h
72 int NumberOfKids();
73 /// a string describing this process roles such as worker or coordinator
74 String ProcessRoles();
75
76 void debug_trap(const char *);
77
78 void logsFlush(void);
79
80 void squid_getrusage(struct rusage *r);
81 double rusage_cputime(struct rusage *r);
82 int rusage_maxrss(struct rusage *r);
83 int rusage_pagefaults(struct rusage *r);
84 void releaseServerSockets(void);
85 void PrintRusage(void);
86 void dumpMallocStats(void);
87
88 #endif /* SQUID_TOOLS_H_ */
89