]> git.ipfire.org Git - thirdparty/squid.git/blame - src/helper/ChildConfig.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / helper / ChildConfig.h
CommitLineData
bbc27441 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
bbc27441
AJ
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
76d9b994
AJ
9#ifndef _SQUID_SRC_HELPER_CHILDCONFIG_H
10#define _SQUID_SRC_HELPER_CHILDCONFIG_H
11
12namespace Helper
13{
48d54e4d
AJ
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 */
76d9b994 21class ChildConfig
10044c9b 22{
48d54e4d 23public:
aca988c4 24 ChildConfig();
f49e4f7b 25 explicit ChildConfig(const unsigned int m);
48d54e4d 26
1af735c7 27 /**
48d54e4d
AJ
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 */
881c4733 34 int needNew() const;
48d54e4d
AJ
35 void parseConfig();
36
1af735c7
AJ
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 loosing any of the active state or causing races.
41 */
76d9b994 42 ChildConfig &updateLimits(const ChildConfig &rhs);
1af735c7 43
48d54e4d
AJ
44 /* values from squid.conf */
45public:
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.
5b708d95 70 * Default: 0 - no concurrency possible.
48d54e4d
AJ
71 */
72 unsigned int concurrency;
73
74 /* derived from active operations */
48d54e4d
AJ
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;
6825b101
CT
87
88 /**
89 * The requests queue size. By default it is of size 2*n_max
90 */
91 unsigned int queue_size;
92
6082a0e2
EB
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
6825b101
CT
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;
a56fcf0b
CT
107
108 /// older stateful helper server reservations may be forgotten
109 time_t reservationTimeout = 64; // reservation-timeout
48d54e4d
AJ
110};
111
76d9b994
AJ
112} // namespace Helper
113
48d54e4d
AJ
114/* Legacy parser interface */
115#define parse_HelperChildConfig(c) (c)->parseConfig()
404cfda1 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)
48d54e4d
AJ
117#define free_HelperChildConfig(dummy) // NO.
118
76d9b994 119#endif /* _SQUID_SRC_HELPER_CHILDCONFIG_H */
f53969cc 120