]>
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 | ||
9a0a18de | 41 | #if USE_DELAY_POOLS |
b67e2c8c | 42 | #include "squid.h" |
43 | #include "DelayBucket.h" | |
44 | #include "DelaySpec.h" | |
45 | #include "Store.h" | |
63be0a78 | 46 | |
b67e2c8c | 47 | void |
48 | DelayBucket::stats(StoreEntry *entry)const | |
49 | { | |
50 | storeAppendPrintf(entry, "%d", level()); | |
51 | } | |
52 | ||
53 | void | |
63be0a78 | 54 | DelayBucket::update(DelaySpec const &rate, int incr) |
b67e2c8c | 55 | { |
56 | if (rate.restore_bps != -1 && | |
62e76326 | 57 | (level() += rate.restore_bps * incr) > rate.max_bytes) |
58 | level() = rate.max_bytes; | |
b67e2c8c | 59 | } |
60 | ||
61 | int | |
63be0a78 | 62 | DelayBucket::bytesWanted(int minimum, int maximum) const |
b67e2c8c | 63 | { |
a748a390 | 64 | int result = max(minimum, min(maximum, level())); |
d576a6a6 | 65 | return result; |
b67e2c8c | 66 | } |
67 | ||
68 | void | |
69 | DelayBucket::bytesIn(int qty) | |
70 | { | |
71 | level() -= qty; | |
72 | } | |
73 | ||
74 | void | |
63be0a78 | 75 | DelayBucket::init(DelaySpec const &rate) |
b67e2c8c | 76 | { |
77 | level() = (int) (((double)rate.max_bytes * | |
62e76326 | 78 | Config.Delay.initial) / 100); |
b67e2c8c | 79 | } |
62e76326 | 80 | |
9a0a18de | 81 | #endif /* USE_DELAY_POOLS */ |