ClientDelayConfig.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 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#include "squid.h"
10#include "acl/Acl.h"
11#include "acl/Gadgets.h"
12#include "ClientDelayConfig.h"
13#include "ConfigParser.h"
14#include "Parsing.h"
15#include "Store.h"
16
18{
19 if (access)
21}
22
23void ClientDelayPool::dump(StoreEntry * entry, unsigned int poolNumberMinusOne) const
24{
25 LOCAL_ARRAY(char, nom, 32);
26 snprintf(nom, 32, "client_delay_access %d", poolNumberMinusOne + 1);
27 dump_acl_access(entry, nom, access);
28 storeAppendPrintf(entry, "client_delay_parameters %d %d %" PRId64 "\n", poolNumberMinusOne + 1, rate,highwatermark);
29 storeAppendPrintf(entry, "\n");
30}
31
34{
36 return &pools;
37}
38
40{
41 pools.clear();
42}
43
44void
46{
47 for (unsigned int i = 0; i < pools().size(); ++i) {
48 /* pools require explicit 'allow' to assign a client into them */
49 if (!pool(i).access) {
50 debugs(77, DBG_IMPORTANT, "WARNING: client_delay_pool #" << (i+1) <<
51 " has no client_delay_access configured. " <<
52 "No client will ever use it.");
53 }
54 }
55}
56
57void ClientDelayConfig::dumpPoolCount(StoreEntry * entry, const char *name) const
58{
59 const auto &pools_ = ClientDelayPools::Instance()->pools;
60 if (pools_.size()) {
61 storeAppendPrintf(entry, "%s %d\n", name, static_cast<int>(pools_.size()));
62 for (unsigned int i = 0; i < pools_.size(); ++i)
63 pools_[i]->dump(entry, i);
64 }
65}
66
67void
69{
70 pools().clear();
71}
72
74{
75 if (pools().size()) {
76 debugs(3, DBG_CRITICAL, "parse_client_delay_pool_count: multiple client_delay_pools lines, " <<
77 "aborting all previous client_delay_pools config");
78 freePools();
79 }
80 unsigned short pools_;
82 for (int i = 0; i < pools_; ++i)
83 pools().push_back(new ClientDelayPool());
84}
85
87{
88 if (unsigned short poolId = parsePoolId()) {
89 --poolId;
90 pool(poolId).rate = GetInteger();
92 }
93}
94
96{
97 if (const unsigned short poolId = parsePoolId())
98 aclParseAccessLine("client_delay_access", parser, &(pool(poolId-1).access));
99}
100
101unsigned short
103{
104 unsigned short poolId = 0;
106 if (poolId < 1 || poolId > pools().size()) {
107 debugs(3, DBG_CRITICAL, "parse_client_delay_pool_rates: Ignoring pool " <<
108 poolId << " not in 1 .. " << pools().size());
109 return 0;
110 }
111 return poolId;
112}
113
int size
Definition: ModDevPoll.cc:75
int64_t GetInteger64(void)
Definition: Parsing.cc:132
int GetInteger(void)
Definition: Parsing.cc:148
void aclParseAccessLine(const char *directive, ConfigParser &, acl_access **treep)
Definition: Gadgets.cc:138
unsigned short parsePoolId()
std::vector< ClientDelayPool::Pointer > & pools()
void finalize()
checks pools configuration
void parsePoolAccess(ConfigParser &parser)
void dumpPoolCount(StoreEntry *entry, const char *name) const
ClientDelayPool & pool(const int i)
void dump(StoreEntry *entry, unsigned int poolNumberMinusOne) const
acl_access * access
std::vector< ClientDelayPool::Pointer > pools
static ClientDelayPools * Instance()
static void ParseUShort(unsigned short *var)
Definition: cache_cf.cc:3127
#define DBG_IMPORTANT
Definition: Stream.h:41
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:196
#define DBG_CRITICAL
Definition: Stream.h:40
void aclDestroyAccessList(acl_access **list)
Definition: Gadgets.cc:279
void dump_acl_access(StoreEntry *entry, const char *name, acl_access *head)
Definition: cache_cf.cc:1515
#define LOCAL_ARRAY(type, name, size)
Definition: squid.h:68
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:828
#define PRId64
Definition: types.h:110

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors