]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/tools.h
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
9 /* DEBUG: section 21 Misc Functions */
11 #ifndef SQUID_TOOLS_H_
12 #define SQUID_TOOLS_H_
16 #include "SquidString.h"
21 extern int DebugSignal
;
23 /// The Squid -n parameter service name.
24 /// Default is APP_SHORTNAME ('squid').
25 extern SBuf service_name
;
27 void kb_incr(kb_t
*, size_t);
28 void parseEtcHosts(void);
30 void setUmask(mode_t mask
);
31 void strwordquote(MemBuf
* mb
, const char *str
);
33 /* packs, then prints an object using debugs() */
34 void debugObj(int section
, int level
, const char *label
, void *obj
, ObjPackMethod pm
);
36 const char *getMyHostname(void);
37 const char *uniqueHostname(void);
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);
46 void writePidFile(void);
49 void setSystemLimits(void);
50 void squid_signal(int sig
, SIGHDLR
*, int flags
);
51 pid_t
readPidFile(void);
52 void keepCapabilities(void);
53 void BroadcastSignalIfAny(int& sig
);
55 /// whether the current process is the parent of all other Squid processes
56 bool IamMasterProcess();
58 * whether the current process is dedicated to doing things that only
59 * a single process should do, such as PID file maintenance and WCCP
61 bool IamPrimaryProcess();
62 /// whether the current process coordinates worker processes
63 bool IamCoordinatorProcess();
64 /// whether the current process handles HTTP transactions and such
65 bool IamWorkerProcess();
66 /// whether the current process is dedicated to managing a cache_dir
67 bool IamDiskProcess();
68 /// Whether we are running in daemon mode
69 bool InDaemonMode(); // try using specific Iam*() checks above first
70 /// Whether there should be more than one worker process running
71 bool UsingSmp(); // try using specific Iam*() checks above first
72 /// number of Kid processes as defined in src/ipc/Kid.h
74 /// a string describing this process roles such as worker or coordinator
75 String
ProcessRoles();
77 void debug_trap(const char *);
81 void squid_getrusage(struct rusage
*r
);
82 double rusage_cputime(struct rusage
*r
);
83 int rusage_maxrss(struct rusage
*r
);
84 int rusage_pagefaults(struct rusage
*r
);
85 void releaseServerSockets(void);
86 void PrintRusage(void);
87 void dumpMallocStats(void);
90 typedef union wait PidStatus
;
92 typedef int PidStatus
;
96 * Compatibility wrapper function for waitpid
97 * \pid the pid of child proccess to wait for.
98 * \param status the exit status returned by waitpid
99 * \param flags WNOHANG or 0
101 pid_t
WaitForOnePid(pid_t pid
, PidStatus
&status
, int flags
);
104 * Wait for state changes in any of the kid processes.
105 * Equivalent to waitpid(-1, ...) system call
106 * \param status the exit status returned by waitpid
107 * \param flags WNOHANG or 0
109 inline pid_t
WaitForAnyPid(PidStatus
&status
, int flags
)
111 return WaitForOnePid(-1, status
, flags
);
114 #endif /* SQUID_TOOLS_H_ */