]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/helper/ChildConfig.cc
2 * Copyright (C) 1996-2017 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.
11 #include "ConfigParser.h"
14 #include "helper/ChildConfig.h"
19 Helper::ChildConfig::ChildConfig():
27 onPersistentOverload(actDie
),
28 defaultQueueSize(true)
31 Helper::ChildConfig::ChildConfig(const unsigned int m
):
39 onPersistentOverload(actDie
),
40 defaultQueueSize(true)
44 Helper::ChildConfig::updateLimits(const Helper::ChildConfig
&rhs
)
46 // Copy the limits only.
47 // Preserve the local state values (n_running and n_active)
49 n_startup
= rhs
.n_startup
;
51 concurrency
= rhs
.concurrency
;
52 queue_size
= rhs
.queue_size
;
53 onPersistentOverload
= rhs
.onPersistentOverload
;
54 defaultQueueSize
= rhs
.defaultQueueSize
;
59 Helper::ChildConfig::needNew() const
61 /* during the startup and reconfigure use our special amount... */
62 if (starting_up
|| reconfiguring
) return n_startup
;
64 /* keep a minimum of n_idle helpers free... */
65 if ( (n_active
+ n_idle
) < n_max
) return n_idle
;
67 /* dont ever start more than n_max processes. */
68 return (n_max
- n_active
);
72 Helper::ChildConfig::parseConfig()
74 char const *token
= ConfigParser::NextToken();
79 /* starts with a bare number for the max... back-compatible */
80 n_max
= xatoui(token
);
83 debugs(0, DBG_CRITICAL
, "ERROR: The maximum number of processes cannot be less than 1.");
87 /* Parse extension options */
88 for (; (token
= ConfigParser::NextToken()) ;) {
89 if (strncmp(token
, "startup=", 8) == 0) {
90 n_startup
= xatoui(token
+ 8);
91 } else if (strncmp(token
, "idle=", 5) == 0) {
92 n_idle
= xatoui(token
+ 5);
94 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Using idle=0 for helpers causes request failures. Overiding to use idle=1 instead.");
97 } else if (strncmp(token
, "concurrency=", 12) == 0) {
98 concurrency
= xatoui(token
+ 12);
99 } else if (strncmp(token
, "queue-size=", 11) == 0) {
100 queue_size
= xatoui(token
+ 11);
101 defaultQueueSize
= false;
102 } else if (strncmp(token
, "on-persistent-overload=", 23) == 0) {
103 const SBuf
action(token
+ 23);
104 if (action
.cmp("ERR") == 0)
105 onPersistentOverload
= actErr
;
106 else if (action
.cmp("die") == 0)
107 onPersistentOverload
= actDie
;
109 debugs(0, DBG_CRITICAL
, "ERROR: Unsupported on-persistent-overloaded action: " << action
);
113 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Undefined option: " << token
<< ".");
120 if (n_startup
> n_max
) {
121 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Capping startup=" << n_startup
<< " to the defined maximum (" << n_max
<<")");
125 if (n_idle
> n_max
) {
126 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Capping idle=" << n_idle
<< " to the defined maximum (" << n_max
<<")");
130 if (defaultQueueSize
)
131 queue_size
= 2 * n_max
;