]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DelaySpec.cc
Merge from trunk rev.13584
[thirdparty/squid.git] / src / DelaySpec.cc
1 /*
2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9 /* DEBUG: section 77 Delay Pools */
10
11 #include "squid.h"
12
13 #if USE_DELAY_POOLS
14 #include "cache_cf.h"
15 #include "DelaySpec.h"
16 #include "Parsing.h"
17 #include "Store.h"
18
19 DelaySpec::DelaySpec() : restore_bps(-1), max_bytes (-1)
20 {}
21
22 void
23 DelaySpec::stats (StoreEntry * sentry, char const *label) const
24 {
25 if (restore_bps == -1) {
26 storeAppendPrintf(sentry, "\t%s:\n\t\tDisabled.\n\n", label);
27 return;
28 }
29
30 storeAppendPrintf(sentry, "\t%s:\n", label);
31 storeAppendPrintf(sentry, "\t\tMax: %" PRId64 "\n", max_bytes);
32 storeAppendPrintf(sentry, "\t\tRestore: %d\n", restore_bps);
33 }
34
35 void
36 DelaySpec::dump (StoreEntry *entry) const
37 {
38 storeAppendPrintf(entry, " %d/%" PRId64 "", restore_bps, max_bytes);
39 }
40
41 void
42 DelaySpec::parse()
43 {
44 int r;
45 char *token;
46 token = strtok(NULL, "/");
47
48 if (token == NULL)
49 self_destruct();
50
51 if (sscanf(token, "%d", &r) != 1)
52 self_destruct();
53
54 restore_bps = r;
55
56 max_bytes = GetInteger64();
57 }
58
59 #endif