]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DelayConfig.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / DelayConfig.cc
1 /*
2 * Copyright (C) 1996-2017 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
9 /* DEBUG: section 77 Delay Pools */
10
11 #include "squid.h"
12
13 #if USE_DELAY_POOLS
14 #include "acl/Acl.h"
15 #include "acl/Gadgets.h"
16 #include "ConfigParser.h"
17 #include "DelayConfig.h"
18 #include "DelayPool.h"
19 #include "DelayPools.h"
20 #include "Store.h"
21
22 void
23 DelayConfig::parsePoolCount()
24 {
25 unsigned short pools_;
26 ConfigParser::ParseUShort(&pools_);
27 DelayPools::pools(pools_);
28 }
29
30 void
31 DelayConfig::parsePoolClass()
32 {
33 unsigned short pool;
34
35 ConfigParser::ParseUShort(&pool);
36
37 if (pool < 1 || pool > DelayPools::pools()) {
38 debugs(3, DBG_CRITICAL, "parse_delay_pool_class: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools());
39 return;
40 }
41
42 unsigned short delay_class_;
43 ConfigParser::ParseUShort(&delay_class_);
44
45 if (delay_class_ < 1 || delay_class_ > 5) {
46 debugs(3, DBG_CRITICAL, "parse_delay_pool_class: Ignoring pool " << pool << " class " << delay_class_ << " not in 1 .. 5");
47 return;
48 }
49
50 --pool;
51
52 DelayPools::delay_data[pool].createPool(delay_class_);
53 }
54
55 void
56 DelayConfig::parsePoolRates()
57 {
58 unsigned short pool;
59 ConfigParser::ParseUShort(&pool);
60
61 if (pool < 1 || pool > DelayPools::pools()) {
62 debugs(3, DBG_CRITICAL, "parse_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools());
63 return;
64 }
65
66 --pool;
67
68 if (!DelayPools::delay_data[pool].theComposite().getRaw()) {
69 debugs(3, DBG_CRITICAL, "parse_delay_pool_rates: Ignoring pool " << pool + 1 << " attempt to set rates with class not set");
70 return;
71 }
72
73 DelayPools::delay_data[pool].parse();
74 }
75
76 void
77 DelayConfig::parsePoolAccess(ConfigParser &parser)
78 {
79 unsigned short pool;
80
81 ConfigParser::ParseUShort(&pool);
82
83 if (pool < 1 || pool > DelayPools::pools()) {
84 debugs(3, DBG_CRITICAL, "parse_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools());
85 return;
86 }
87
88 --pool;
89 aclParseAccessLine("delay_access", parser, &DelayPools::delay_data[pool].access);
90 }
91
92 void
93 DelayConfig::freePoolCount()
94 {
95 DelayPools::FreePools();
96 initial = 50;
97 }
98
99 void
100 DelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const
101 {
102 int i;
103
104 if (!DelayPools::pools()) {
105 storeAppendPrintf(entry, "%s 0\n", name);
106 return;
107 }
108
109 storeAppendPrintf(entry, "%s %d\n", name, DelayPools::pools());
110
111 for (i = 0; i < DelayPools::pools(); ++i)
112 DelayPools::delay_data[i].dump (entry, i);
113 }
114
115 #endif /* USE_DELAY_POOLS */
116