]>
Commit | Line | Data |
---|---|---|
b67e2c8c | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
b67e2c8c | 3 | * |
bbc27441 AJ |
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. | |
b67e2c8c | 7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 77 Delay Pools */ |
10 | ||
f7f3304a | 11 | #include "squid.h" |
b67e2c8c | 12 | |
9a0a18de | 13 | #if USE_DELAY_POOLS |
b67e2c8c | 14 | #include "DelayBucket.h" |
15 | #include "DelaySpec.h" | |
4d5904f7 | 16 | #include "SquidConfig.h" |
b67e2c8c | 17 | #include "Store.h" |
63be0a78 | 18 | |
b67e2c8c | 19 | void |
20 | DelayBucket::stats(StoreEntry *entry)const | |
21 | { | |
22 | storeAppendPrintf(entry, "%d", level()); | |
23 | } | |
24 | ||
25 | void | |
63be0a78 | 26 | DelayBucket::update(DelaySpec const &rate, int incr) |
b67e2c8c | 27 | { |
28 | if (rate.restore_bps != -1 && | |
62e76326 | 29 | (level() += rate.restore_bps * incr) > rate.max_bytes) |
30 | level() = rate.max_bytes; | |
b67e2c8c | 31 | } |
32 | ||
33 | int | |
63be0a78 | 34 | DelayBucket::bytesWanted(int minimum, int maximum) const |
b67e2c8c | 35 | { |
a748a390 | 36 | int result = max(minimum, min(maximum, level())); |
d576a6a6 | 37 | return result; |
b67e2c8c | 38 | } |
39 | ||
40 | void | |
41 | DelayBucket::bytesIn(int qty) | |
42 | { | |
43 | level() -= qty; | |
44 | } | |
45 | ||
46 | void | |
63be0a78 | 47 | DelayBucket::init(DelaySpec const &rate) |
b67e2c8c | 48 | { |
49 | level() = (int) (((double)rate.max_bytes * | |
62e76326 | 50 | Config.Delay.initial) / 100); |
b67e2c8c | 51 | } |
62e76326 | 52 | |
9a0a18de | 53 | #endif /* USE_DELAY_POOLS */ |
f53969cc | 54 |