]> git.ipfire.org Git - thirdparty/squid.git/blame - src/DelayConfig.cc
Summary: Merge comms refactoring to CVS.
[thirdparty/squid.git] / src / DelayConfig.cc
CommitLineData
b67e2c8c 1
2/*
62e76326 3 * $Id: DelayConfig.cc,v 1.4 2003/02/21 22:50:05 robertc Exp $
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.
26 *
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.
31 *
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
42#if DELAY_POOLS
43#include "squid.h"
44#include "DelayConfig.h"
45#include "Config.h"
46#include "DelayPools.h"
47#include "DelayPool.h"
48#include "Store.h"
8000a965 49#include "ACL.h"
b67e2c8c 50
51void
52DelayConfig::parsePoolCount()
53{
54 u_short pools_;
55 ConfigParser::ParseUShort(&pools_);
56 DelayPools::pools(pools_);
57}
58
59void
60DelayConfig::parsePoolClass()
61{
62 ushort pool;
63
64 ConfigParser::ParseUShort(&pool);
62e76326 65
b67e2c8c 66 if (pool < 1 || pool > DelayPools::pools()) {
62e76326 67 debug(3, 0) ("parse_delay_pool_class: Ignoring pool %d not in 1 .. %d\n", pool, DelayPools::pools());
68 return;
b67e2c8c 69 }
62e76326 70
b67e2c8c 71 ushort delay_class_;
72 ConfigParser::ParseUShort(&delay_class_);
62e76326 73
2f44bd34 74 if (delay_class_ < 1 || delay_class_ > 4) {
62e76326 75 debug(3, 0) ("parse_delay_pool_class: Ignoring pool %d class %d not in 1 .. 4\n", pool, delay_class_);
76 return;
b67e2c8c 77 }
62e76326 78
b67e2c8c 79 pool--;
80
81 DelayPools::delay_data[pool].createPool(delay_class_);
82}
83
84void
85DelayConfig::parsePoolRates()
86{
87 ushort pool;
88 ConfigParser::ParseUShort(&pool);
62e76326 89
b67e2c8c 90 if (pool < 1 || pool > DelayPools::pools()) {
62e76326 91 debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d not in 1 .. %d\n", pool, DelayPools::pools());
92 return;
b67e2c8c 93 }
62e76326 94
b67e2c8c 95 pool--;
96
97 if (!DelayPools::delay_data[pool].theComposite().getRaw()) {
62e76326 98 debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d attempt to set rates with class not set\n", pool + 1);
99 return;
b67e2c8c 100 }
62e76326 101
b67e2c8c 102 DelayPools::delay_data[pool].parse();
103}
104
105void
106DelayConfig::parsePoolAccess()
107{
108 ushort pool;
109
110 ConfigParser::ParseUShort(&pool);
62e76326 111
b67e2c8c 112 if (pool < 1 || pool > DelayPools::pools()) {
62e76326 113 debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d not in 1 .. %d\n", pool, DelayPools::pools());
114 return;
b67e2c8c 115 }
62e76326 116
b67e2c8c 117 --pool;
118 aclParseAccessLine(&DelayPools::delay_data[pool].access);
119}
120
121void
122DelayConfig::freePoolCount()
123{
124 DelayPools::FreePools();
125 initial = 50;
126}
127
128void
129DelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const
130{
131 int i;
132
133 if (!DelayPools::pools()) {
62e76326 134 storeAppendPrintf(entry, "%s 0\n", name);
135 return;
b67e2c8c 136 }
62e76326 137
b67e2c8c 138 storeAppendPrintf(entry, "%s %d\n", name, DelayPools::pools());
62e76326 139
b67e2c8c 140 for (i = 0; i < DelayPools::pools(); i++)
62e76326 141 DelayPools::delay_data[i].dump (entry, i);
b67e2c8c 142}
62e76326 143
b67e2c8c 144#endif