]>
Commit | Line | Data |
---|---|---|
bbc27441 AJ |
1 | /* |
2 | * Copyright (C) 1996-2014 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 | ||
14a7bbc7 | 9 | #include "squid.h" |
582c2af2 FC |
10 | #include "acl/Acl.h" |
11 | #include "acl/Gadgets.h" | |
14a7bbc7 | 12 | #include "ClientDelayConfig.h" |
582c2af2 | 13 | #include "ConfigParser.h" |
14a7bbc7 CT |
14 | #include "Parsing.h" |
15 | #include "Store.h" | |
14a7bbc7 CT |
16 | |
17 | void ClientDelayPool::dump(StoreEntry * entry, unsigned int poolNumberMinusOne) const | |
18 | { | |
19 | LOCAL_ARRAY(char, nom, 32); | |
20 | snprintf(nom, 32, "client_delay_access %d", poolNumberMinusOne + 1); | |
21 | dump_acl_access(entry, nom, access); | |
c91ca3ce | 22 | storeAppendPrintf(entry, "client_delay_parameters %d %d %" PRId64 "\n", poolNumberMinusOne + 1, rate,highwatermark); |
14a7bbc7 CT |
23 | storeAppendPrintf(entry, "\n"); |
24 | } | |
25 | ||
26 | void | |
27 | ClientDelayConfig::finalize() | |
28 | { | |
29 | for (unsigned int i = 0; i < pools.size(); ++i) { | |
30 | /* pools require explicit 'allow' to assign a client into them */ | |
31 | if (!pools[i].access) { | |
32 | debugs(77, DBG_IMPORTANT, "client_delay_pool #" << (i+1) << | |
f33d34a8 A |
33 | " has no client_delay_access configured. " << |
34 | "No client will ever use it."); | |
35 | } | |
36 | } | |
14a7bbc7 CT |
37 | } |
38 | ||
39 | void ClientDelayConfig::freePoolCount() | |
40 | { | |
c33a88ca | 41 | pools.clear(); |
14a7bbc7 CT |
42 | } |
43 | ||
44 | void ClientDelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const | |
45 | { | |
46 | if (pools.size()) { | |
47 | storeAppendPrintf(entry, "%s %d\n", name, (int)pools.size()); | |
95dc7ff4 | 48 | for (unsigned int i = 0; i < pools.size(); ++i) |
14a7bbc7 CT |
49 | pools[i].dump(entry, i); |
50 | } | |
51 | } | |
52 | ||
53 | void ClientDelayConfig::parsePoolCount() | |
54 | { | |
55 | if (pools.size()) { | |
fa84c01d | 56 | debugs(3, DBG_CRITICAL, "parse_client_delay_pool_count: multiple client_delay_pools lines, aborting all previous client_delay_pools config"); |
14a7bbc7 CT |
57 | clean(); |
58 | } | |
f45dd259 | 59 | unsigned short pools_; |
14a7bbc7 | 60 | ConfigParser::ParseUShort(&pools_); |
95dc7ff4 | 61 | for (int i = 0; i < pools_; ++i) { |
14a7bbc7 CT |
62 | pools.push_back(ClientDelayPool()); |
63 | } | |
64 | } | |
65 | ||
66 | void ClientDelayConfig::parsePoolRates() | |
67 | { | |
f45dd259 | 68 | unsigned short pool; |
14a7bbc7 CT |
69 | ConfigParser::ParseUShort(&pool); |
70 | ||
71 | if (pool < 1 || pool > pools.size()) { | |
fa84c01d | 72 | debugs(3, DBG_CRITICAL, "parse_client_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << pools.size()); |
14a7bbc7 CT |
73 | return; |
74 | } | |
75 | ||
5e263176 | 76 | --pool; |
14a7bbc7 CT |
77 | |
78 | pools[pool].rate = GetInteger(); | |
79 | pools[pool].highwatermark = GetInteger64(); | |
80 | } | |
81 | ||
82 | void ClientDelayConfig::parsePoolAccess(ConfigParser &parser) | |
83 | { | |
f45dd259 | 84 | unsigned short pool; |
14a7bbc7 CT |
85 | |
86 | ConfigParser::ParseUShort(&pool); | |
87 | ||
88 | if (pool < 1 || pool > pools.size()) { | |
fa84c01d | 89 | debugs(3, DBG_CRITICAL, "parse_client_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << pools.size()); |
14a7bbc7 CT |
90 | return; |
91 | } | |
92 | ||
93 | --pool; | |
6f58d7d7 | 94 | aclParseAccessLine("client_delay_access", parser, &pools[pool].access); |
14a7bbc7 CT |
95 | } |
96 | ||
97 | void ClientDelayConfig::clean() | |
98 | { | |
95dc7ff4 | 99 | for (unsigned int i = 0; i < pools.size(); ++i) { |
14a7bbc7 CT |
100 | aclDestroyAccessList(&pools[i].access); |
101 | } | |
102 | } | |
f53969cc | 103 |