]>
Commit | Line | Data |
---|---|---|
b67e2c8c | 1 | /* |
262a0e14 | 2 | * $Id$ |
b67e2c8c | 3 | * |
4 | * DEBUG: section 77 Delay Pools | |
5 | * AUTHOR: Robert Collins <robertc@squid-cache.org> | |
6 | * Based upon original delay pools code by | |
7 | * David Luyer <david@luyer.net> | |
8 | * | |
9 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
10 | * ---------------------------------------------------------- | |
11 | * | |
12 | * Squid is the result of efforts by numerous individuals from | |
13 | * the Internet community; see the CONTRIBUTORS file for full | |
14 | * details. Many organizations have provided support for Squid's | |
15 | * development; see the SPONSORS file for full details. Squid is | |
16 | * Copyrighted (C) 2001 by the Regents of the University of | |
17 | * California; see the COPYRIGHT file for full details. Squid | |
18 | * incorporates software developed and/or copyrighted by other | |
19 | * sources; see the CREDITS file for full details. | |
20 | * | |
21 | * This program is free software; you can redistribute it and/or modify | |
22 | * it under the terms of the GNU General Public License as published by | |
23 | * the Free Software Foundation; either version 2 of the License, or | |
24 | * (at your option) any later version. | |
26ac0430 | 25 | * |
b67e2c8c | 26 | * This program is distributed in the hope that it will be useful, |
27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
29 | * GNU General Public License for more details. | |
26ac0430 | 30 | * |
b67e2c8c | 31 | * You should have received a copy of the GNU General Public License |
32 | * along with this program; if not, write to the Free Software | |
33 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
34 | * | |
35 | * | |
36 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
37 | */ | |
38 | ||
39 | #include "config.h" | |
40 | ||
41 | #if DELAY_POOLS | |
42 | #include "squid.h" | |
43 | #include "DelayBucket.h" | |
44 | #include "DelaySpec.h" | |
45 | #include "Store.h" | |
63be0a78 | 46 | |
47 | #if DEAD_CODE // ? | |
b67e2c8c | 48 | #include "DelayPools.h" |
49 | #include "StoreClient.h" | |
50 | #include "MemObject.h" | |
51 | #include "client_side_request.h" | |
52 | #include "ACLChecklist.h" | |
53 | #include "ACL.h" | |
a80a77cf | 54 | #include "ConfigParser.h" |
b67e2c8c | 55 | #include "DelayId.h" |
56 | #include "Array.h" | |
30abd221 | 57 | #include "String.h" |
b67e2c8c | 58 | #include "CommonPool.h" |
59 | #include "CompositePoolNode.h" | |
60 | #include "DelayPool.h" | |
61 | #include "DelayVector.h" | |
62 | #include "NullDelayId.h" | |
63be0a78 | 63 | #endif |
b67e2c8c | 64 | |
65 | void | |
66 | DelayBucket::stats(StoreEntry *entry)const | |
67 | { | |
68 | storeAppendPrintf(entry, "%d", level()); | |
69 | } | |
70 | ||
71 | void | |
63be0a78 | 72 | DelayBucket::update(DelaySpec const &rate, int incr) |
b67e2c8c | 73 | { |
74 | if (rate.restore_bps != -1 && | |
62e76326 | 75 | (level() += rate.restore_bps * incr) > rate.max_bytes) |
76 | level() = rate.max_bytes; | |
b67e2c8c | 77 | } |
78 | ||
79 | int | |
63be0a78 | 80 | DelayBucket::bytesWanted(int minimum, int maximum) const |
b67e2c8c | 81 | { |
a748a390 | 82 | int result = max(minimum, min(maximum, level())); |
d576a6a6 | 83 | return result; |
b67e2c8c | 84 | } |
85 | ||
86 | void | |
87 | DelayBucket::bytesIn(int qty) | |
88 | { | |
89 | level() -= qty; | |
90 | } | |
91 | ||
92 | void | |
63be0a78 | 93 | DelayBucket::init(DelaySpec const &rate) |
b67e2c8c | 94 | { |
95 | level() = (int) (((double)rate.max_bytes * | |
62e76326 | 96 | Config.Delay.initial) / 100); |
b67e2c8c | 97 | } |
62e76326 | 98 | |
b67e2c8c | 99 | #endif |