]> git.ipfire.org Git - thirdparty/squid.git/blob - src/helper/ChildConfig.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / helper / ChildConfig.h
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 #ifndef _SQUID_SRC_HELPER_CHILDCONFIG_H
10 #define _SQUID_SRC_HELPER_CHILDCONFIG_H
11
12 namespace Helper
13 {
14
15 /**
16 * Contains statistics of a particular type of child helper.
17 *
18 * Some derived from a helper children configuration option,
19 * some from runtime stats on the currently active children.
20 */
21 class ChildConfig
22 {
23 public:
24 ChildConfig();
25 explicit ChildConfig(const unsigned int m);
26
27 /**
28 * When new helpers are needed call this to find out how many more
29 * we are allowed to start.
30 * \retval 0 No more helpers may be started right now.
31 * \retval N < 0 Error. No more helpers may be started.
32 * \retval N N more helpers may be started immediately.
33 */
34 int needNew() const;
35 void parseConfig();
36
37 /**
38 * Update an existing set of details with new start/max/idle/concurrent limits.
39 * This is for parsing new child settings into an object incrementally then updating
40 * the running set without losing any of the active state or causing races.
41 */
42 ChildConfig &updateLimits(const ChildConfig &rhs);
43
44 /* values from squid.conf */
45 public:
46
47 /** maximum child process limits. How many of this helper the system can cope with */
48 unsigned int n_max;
49
50 /**
51 * Number of children to kick off at startup.
52 * set via the startup=N option.
53 *
54 * By default if undefined 1 will be started immediately for use.
55 * The minimum/idle amount will be scheduled for starting as soon as possible after startup is completed.
56 */
57 unsigned int n_startup;
58
59 /**
60 * Number of helper children to keep available as a buffer against sudden bursts of requests.
61 * set via the idle=N option. May be zero.
62 *
63 * The default value for backward compatibility the default for this is the same as maximum children.
64 * For now the actual number of idle children is only reduced by a reconfigure operation. This may change.
65 */
66 unsigned int n_idle;
67
68 /**
69 * How many concurrent requests each child helper may be capable of handling.
70 * Default: 0 - no concurrency possible.
71 */
72 unsigned int concurrency;
73
74 /* derived from active operations */
75
76 /**
77 * Total helper children objects currently existing.
78 * Produced as a side effect of starting children or their stopping.
79 */
80 unsigned int n_running;
81
82 /**
83 * Count of helper children active (not shutting down).
84 * This includes both idle and in-use children.
85 */
86 unsigned int n_active;
87
88 /**
89 * The requests queue size. By default it is of size 2*n_max
90 */
91 unsigned int queue_size;
92
93 /// how to handle a serious problem with a helper request submission
94 enum SubmissionErrorHandlingAction {
95 actDie, ///< kill the caller process (i.e., Squid worker)
96 actErr ///< drop the request and send an error to the caller
97 };
98 /// how to handle a new request for helper that was overloaded for too long
99 SubmissionErrorHandlingAction onPersistentOverload;
100
101 /**
102 * True if the default queue size is used.
103 * Needed in the cases where we need to adjust default queue_size in
104 * special configurations, for example when redirector_bypass is used.
105 */
106 bool defaultQueueSize;
107
108 /// older stateful helper server reservations may be forgotten
109 time_t reservationTimeout = 64; // reservation-timeout
110 };
111
112 } // namespace Helper
113
114 /* Legacy parser interface */
115 #define parse_HelperChildConfig(c) (c)->parseConfig()
116 #define dump_HelperChildConfig(e,n,c) storeAppendPrintf((e), "\n%s %d startup=%d idle=%d concurrency=%d\n", (n), (c).n_max, (c).n_startup, (c).n_idle, (c).concurrency)
117 #define free_HelperChildConfig(dummy) // NO.
118
119 #endif /* _SQUID_SRC_HELPER_CHILDCONFIG_H */
120