]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HelperChildConfig.cc
2 * Copyright (C) 1996-2014 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 "HelperChildConfig.h"
19 HelperChildConfig::HelperChildConfig(const unsigned int m
):
29 HelperChildConfig::updateLimits(const HelperChildConfig
&rhs
)
31 // Copy the limits only.
32 // Preserve the local state values (n_running and n_active)
34 n_startup
= rhs
.n_startup
;
36 concurrency
= rhs
.concurrency
;
41 HelperChildConfig::needNew() const
43 /* during the startup and reconfigure use our special amount... */
44 if (starting_up
|| reconfiguring
) return n_startup
;
46 /* keep a minimum of n_idle helpers free... */
47 if ( (n_active
+ n_idle
) < n_max
) return n_idle
;
49 /* dont ever start more than n_max processes. */
50 return (n_max
- n_active
);
54 HelperChildConfig::parseConfig()
56 char const *token
= ConfigParser::NextToken();
61 /* starts with a bare number for the max... back-compatible */
62 n_max
= xatoui(token
);
65 debugs(0, DBG_CRITICAL
, "ERROR: The maximum number of processes cannot be less than 1.");
69 /* Parse extension options */
70 for (; (token
= ConfigParser::NextToken()) ;) {
71 if (strncmp(token
, "startup=", 8) == 0) {
72 n_startup
= xatoui(token
+ 8);
73 } else if (strncmp(token
, "idle=", 5) == 0) {
74 n_idle
= xatoui(token
+ 5);
76 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Using idle=0 for helpers causes request failures. Overiding to use idle=1 instead.");
79 } else if (strncmp(token
, "concurrency=", 12) == 0) {
80 concurrency
= xatoui(token
+ 12);
82 debugs(0, DBG_PARSE_NOTE(DBG_IMPORTANT
), "ERROR: Undefined option: " << token
<< ".");
89 if (n_startup
> n_max
) {
90 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Capping startup=" << n_startup
<< " to the defined maximum (" << n_max
<<")");
95 debugs(0, DBG_CRITICAL
, "WARNING OVERIDE: Capping idle=" << n_idle
<< " to the defined maximum (" << n_max
<<")");