]> git.ipfire.org Git - thirdparty/squid.git/blame - src/DelayConfig.cc
Policy: use USE_* from code wrappers and ENABLE_* for conditionals.
[thirdparty/squid.git] / src / DelayConfig.cc
CommitLineData
b67e2c8c 1
2/*
262a0e14 3 * $Id$
b67e2c8c 4 *
5 * DEBUG: section 77 Delay Pools
6 * AUTHOR: Robert Collins <robertc@squid-cache.org>
7 * Based upon original delay pools code by
8 * David Luyer <david@luyer.net>
9 *
10 * SQUID Web Proxy Cache http://www.squid-cache.org/
11 * ----------------------------------------------------------
12 *
13 * Squid is the result of efforts by numerous individuals from
14 * the Internet community; see the CONTRIBUTORS file for full
15 * details. Many organizations have provided support for Squid's
16 * development; see the SPONSORS file for full details. Squid is
17 * Copyrighted (C) 2001 by the Regents of the University of
18 * California; see the COPYRIGHT file for full details. Squid
19 * incorporates software developed and/or copyrighted by other
20 * sources; see the CREDITS file for full details.
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 2 of the License, or
25 * (at your option) any later version.
26ac0430 26 *
b67e2c8c 27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
26ac0430 31 *
b67e2c8c 32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
35 *
36 *
37 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
38 */
39
40#include "config.h"
41
9a0a18de 42#if USE_DELAY_POOLS
b67e2c8c 43#include "squid.h"
44#include "DelayConfig.h"
a80a77cf 45#include "ConfigParser.h"
b67e2c8c 46#include "DelayPools.h"
47#include "DelayPool.h"
48#include "Store.h"
3ad63615
AR
49#include "acl/Acl.h"
50#include "acl/Gadgets.h"
b67e2c8c 51
52void
53DelayConfig::parsePoolCount()
54{
55 u_short pools_;
56 ConfigParser::ParseUShort(&pools_);
57 DelayPools::pools(pools_);
58}
59
60void
61DelayConfig::parsePoolClass()
62{
63 ushort pool;
64
65 ConfigParser::ParseUShort(&pool);
62e76326 66
b67e2c8c 67 if (pool < 1 || pool > DelayPools::pools()) {
bf8fe701 68 debugs(3, 0, "parse_delay_pool_class: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools());
62e76326 69 return;
b67e2c8c 70 }
62e76326 71
b67e2c8c 72 ushort delay_class_;
73 ConfigParser::ParseUShort(&delay_class_);
62e76326 74
1e5562e3 75 if (delay_class_ < 1 || delay_class_ > 5) {
bf8fe701 76 debugs(3, 0, "parse_delay_pool_class: Ignoring pool " << pool << " class " << delay_class_ << " not in 1 .. 5");
62e76326 77 return;
b67e2c8c 78 }
62e76326 79
b67e2c8c 80 pool--;
81
82 DelayPools::delay_data[pool].createPool(delay_class_);
83}
84
85void
86DelayConfig::parsePoolRates()
87{
88 ushort pool;
89 ConfigParser::ParseUShort(&pool);
62e76326 90
b67e2c8c 91 if (pool < 1 || pool > DelayPools::pools()) {
bf8fe701 92 debugs(3, 0, "parse_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools());
62e76326 93 return;
b67e2c8c 94 }
62e76326 95
b67e2c8c 96 pool--;
97
98 if (!DelayPools::delay_data[pool].theComposite().getRaw()) {
bf8fe701 99 debugs(3, 0, "parse_delay_pool_rates: Ignoring pool " << pool + 1 << " attempt to set rates with class not set");
62e76326 100 return;
b67e2c8c 101 }
62e76326 102
b67e2c8c 103 DelayPools::delay_data[pool].parse();
104}
105
106void
a9f20260 107DelayConfig::parsePoolAccess(ConfigParser &parser)
b67e2c8c 108{
109 ushort pool;
110
111 ConfigParser::ParseUShort(&pool);
62e76326 112
b67e2c8c 113 if (pool < 1 || pool > DelayPools::pools()) {
bf8fe701 114 debugs(3, 0, "parse_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools());
62e76326 115 return;
b67e2c8c 116 }
62e76326 117
b67e2c8c 118 --pool;
a9f20260 119 aclParseAccessLine(parser, &DelayPools::delay_data[pool].access);
b67e2c8c 120}
121
122void
123DelayConfig::freePoolCount()
124{
125 DelayPools::FreePools();
126 initial = 50;
127}
128
129void
130DelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const
131{
132 int i;
133
134 if (!DelayPools::pools()) {
62e76326 135 storeAppendPrintf(entry, "%s 0\n", name);
136 return;
b67e2c8c 137 }
62e76326 138
b67e2c8c 139 storeAppendPrintf(entry, "%s %d\n", name, DelayPools::pools());
62e76326 140
b67e2c8c 141 for (i = 0; i < DelayPools::pools(); i++)
62e76326 142 DelayPools::delay_data[i].dump (entry, i);
b67e2c8c 143}
62e76326 144
9a0a18de 145#endif /* USE_DELAY_POOLS */