]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/helper/ChildConfig.cc
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.
11 #include "ConfigParser.h"
14 #include "helper/ChildConfig.h"
19 Helper::ChildConfig::ChildConfig():
27 defaultQueueSize(true)
30 Helper::ChildConfig::ChildConfig(const unsigned int m
):
38 defaultQueueSize(true)
42 Helper::ChildConfig::updateLimits(const Helper::ChildConfig
&rhs
)
44 // Copy the limits only.
45 // Preserve the local state values (n_running and n_active)
47 n_startup
= rhs
.n_startup
;
49 concurrency
= rhs
.concurrency
;
50 queue_size
= rhs
.queue_size
;
51 defaultQueueSize
= rhs
.defaultQueueSize
;
56 Helper::ChildConfig::needNew() const
58 /* during the startup and reconfigure use our special amount... */
59 if (starting_up
|| reconfiguring
) return n_startup
;
61 /* keep a minimum of n_idle helpers free... */
62 if ( (n_active
+ n_idle
) < n_max
) return n_idle
;
64 /* dont ever start more than n_max processes. */
65 return (n_max
- n_active
);
69 Helper::ChildConfig::parseConfig()
71 char const *token
= ConfigParser::NextToken();
76 /* starts with a bare number for the max... back-compatible */
77 n_max
= xatoui(token
);
80 debugs(0, DBG_CRITICAL
, "ERROR: The maximum number of processes cannot be less than 1.");
84 /* Parse extension options */
85 for (; (token
= ConfigParser::NextToken()) ;) {
86 if (strncmp(token
, "startup=", 8) == 0) {
87 n_startup
= xatoui(token
+ 8);
88 } else if (strncmp(token
, "idle=", 5) == 0) {
89 n_idle
= xatoui(token
+ 5);
91 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Using idle=0 for helpers causes request failures. Overiding to use idle=1 instead.");
94 } else if (strncmp(token
, "concurrency=", 12) == 0) {
95 concurrency
= xatoui(token
+ 12);
96 } else if (strncmp(token
, "queue-size=", 11) == 0) {
97 queue_size
= xatoui(token
+ 11);
98 defaultQueueSize
= false;
100 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Undefined option: " << token
<< ".");
107 if (n_startup
> n_max
) {
108 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Capping startup=" << n_startup
<< " to the defined maximum (" << n_max
<<")");
112 if (n_idle
> n_max
) {
113 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Capping idle=" << n_idle
<< " to the defined maximum (" << n_max
<<")");
117 if (defaultQueueSize
)
118 queue_size
= 2 * n_max
;