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