]>
Commit | Line | Data |
---|---|---|
b67e2c8c | 1 | /* |
bf95c10a | 2 | * Copyright (C) 1996-2022 The Squid Software Foundation and contributors |
26ac0430 | 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 |
8a01b99e | 14 | #include "cache_cf.h" |
b67e2c8c | 15 | #include "DelaySpec.h" |
c8709c9f | 16 | #include "Parsing.h" |
582c2af2 | 17 | #include "Store.h" |
b67e2c8c | 18 | |
19 | DelaySpec::DelaySpec() : restore_bps(-1), max_bytes (-1) | |
62e76326 | 20 | {} |
b67e2c8c | 21 | |
22 | void | |
23 | DelaySpec::stats (StoreEntry * sentry, char const *label) const | |
24 | { | |
25 | if (restore_bps == -1) { | |
62e76326 | 26 | storeAppendPrintf(sentry, "\t%s:\n\t\tDisabled.\n\n", label); |
27 | return; | |
b67e2c8c | 28 | } |
62e76326 | 29 | |
b67e2c8c | 30 | storeAppendPrintf(sentry, "\t%s:\n", label); |
c91ca3ce | 31 | storeAppendPrintf(sentry, "\t\tMax: %" PRId64 "\n", max_bytes); |
b67e2c8c | 32 | storeAppendPrintf(sentry, "\t\tRestore: %d\n", restore_bps); |
33 | } | |
34 | ||
35 | void | |
36 | DelaySpec::dump (StoreEntry *entry) const | |
37 | { | |
c91ca3ce | 38 | storeAppendPrintf(entry, " %d/%" PRId64 "", restore_bps, max_bytes); |
b67e2c8c | 39 | } |
40 | ||
41 | void | |
42 | DelaySpec::parse() | |
43 | { | |
6e7502cc AJ |
44 | // get the token. |
45 | char *token = ConfigParser::NextToken(); | |
b9e4cf09 | 46 | if (!token) { |
62e76326 | 47 | self_destruct(); |
b9e4cf09 AJ |
48 | return; |
49 | } | |
62e76326 | 50 | |
6e7502cc AJ |
51 | // no-limit value |
52 | if (strcmp(token, "none") == 0 || token[0] == '-') { | |
53 | restore_bps = -1; | |
54 | max_bytes = -1; | |
55 | return; | |
56 | } | |
62e76326 | 57 | |
6e7502cc | 58 | // parse the first digits into restore_bps |
aee3523a | 59 | const char *p = nullptr; |
c86f8090 | 60 | if (!StringToInt(token, restore_bps, &p, 10) || *p != '/') { |
6e7502cc AJ |
61 | debugs(77, DBG_CRITICAL, "ERROR: invalid delay rate '" << token << "'. Expecting restore/max or 'none'."); |
62 | self_destruct(); | |
63 | } | |
64 | p++; // increment past the '/' | |
62e76326 | 65 | |
6e7502cc | 66 | // parse the rest into max_bytes |
aee3523a | 67 | if (!StringToInt64(p, max_bytes, nullptr, 10)) { |
6e7502cc AJ |
68 | debugs(77, DBG_CRITICAL, "ERROR: restore rate in '" << token << "' is not a number."); |
69 | self_destruct(); | |
70 | } | |
b67e2c8c | 71 | } |
62e76326 | 72 | |
b67e2c8c | 73 | #endif |
f53969cc | 74 |