]> git.ipfire.org Git - thirdparty/squid.git/blob - src/tools.h
Merged from trunk rev.13515
[thirdparty/squid.git] / src / tools.h
1 /*
2 * DEBUG: section 21 Misc Functions
3 * AUTHOR: Harvest Derived
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
30 *
31 */
32
33 #ifndef SQUID_TOOLS_H_
34 #define SQUID_TOOLS_H_
35
36 #include "Packer.h"
37 #include "SBuf.h"
38 #include "SquidString.h"
39 #include "typedefs.h"
40
41 class MemBuf;
42
43 extern int DebugSignal;
44
45 /// The Squid -n parameter service name.
46 /// Default is APP_SHORTNAME ('squid').
47 extern SBuf service_name;
48
49 void kb_incr(kb_t *, size_t);
50 void parseEtcHosts(void);
51 int getMyPort(void);
52 void setUmask(mode_t mask);
53 void strwordquote(MemBuf * mb, const char *str);
54
55 /* packs, then prints an object using debugs() */
56 void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm);
57
58 const char *getMyHostname(void);
59 const char *uniqueHostname(void);
60
61 void death(int sig);
62 void sigusr2_handle(int sig);
63 void sig_child(int sig);
64 void sig_shutdown(int sig); ///< handles shutdown notifications from kids
65 void leave_suid(void);
66 void enter_suid(void);
67 void no_suid(void);
68 void writePidFile(void);
69 void setMaxFD(void);
70 void setSystemLimits(void);
71 void squid_signal(int sig, SIGHDLR *, int flags);
72 pid_t readPidFile(void);
73 void keepCapabilities(void);
74 void BroadcastSignalIfAny(int& sig);
75
76 /// whether the current process is the parent of all other Squid processes
77 bool IamMasterProcess();
78 /**
79 * whether the current process is dedicated to doing things that only
80 * a single process should do, such as PID file maintenance and WCCP
81 */
82 bool IamPrimaryProcess();
83 /// whether the current process coordinates worker processes
84 bool IamCoordinatorProcess();
85 /// whether the current process handles HTTP transactions and such
86 bool IamWorkerProcess();
87 /// whether the current process is dedicated to managing a cache_dir
88 bool IamDiskProcess();
89 /// Whether we are running in daemon mode
90 bool InDaemonMode(); // try using specific Iam*() checks above first
91 /// Whether there should be more than one worker process running
92 bool UsingSmp(); // try using specific Iam*() checks above first
93 /// number of Kid processes as defined in src/ipc/Kid.h
94 int NumberOfKids();
95 /// a string describing this process roles such as worker or coordinator
96 String ProcessRoles();
97
98 void debug_trap(const char *);
99
100 void logsFlush(void);
101
102 void squid_getrusage(struct rusage *r);
103 double rusage_cputime(struct rusage *r);
104 int rusage_maxrss(struct rusage *r);
105 int rusage_pagefaults(struct rusage *r);
106 void releaseServerSockets(void);
107 void PrintRusage(void);
108 void dumpMallocStats(void);
109
110 #endif /* SQUID_TOOLS_H_ */