DelayTagged.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 "comm/Connection.h"
15 #include "DelayTagged.h"
16 #include "NullDelayId.h"
17 #include "Store.h"
18 
20 {
22 }
23 
25 
27 {
29  buckets.destroy(DelayTaggedFree);
30 }
31 
33 
34 int
36 {
37  /* for rate limiting, case insensitive */
38  return left->tag.caseCmp(right->tag);
39 }
40 
41 void
43 {}
44 
48  void operator() (DelayTaggedBucket::Pointer const &current) {
49  current->stats(sentry);
50  }
51 };
52 
53 void
55 {
56  spec.stats (sentry, "Per Tag");
57 
58  if (spec.restore_bps == -1)
59  return;
60 
61  storeAppendPrintf(sentry, "\t\tCurrent: ");
62 
63  if (buckets.empty()) {
64  storeAppendPrintf (sentry, "Not used yet.\n\n");
65  return;
66  }
67 
68  DelayTaggedStatsVisitor visitor(sentry);
69  buckets.visit(visitor);
70  storeAppendPrintf(sentry, "\n\n");
71 }
72 
73 void
75 {
76  spec.dump(entry);
77 }
78 
80  DelayTaggedUpdater (DelaySpec &_spec, int _incr):spec(_spec),incr(_incr) {};
81 
83  int incr;
84 };
85 
89  void operator() (DelayTaggedBucket::Pointer const &current) {
90  const_cast<DelayTaggedBucket *>(current.getRaw())->theBucket.update(updater->spec, updater->incr);
91  }
92 };
93 
94 void
96 {
97  DelayTaggedUpdater updater(spec, incr);
98  DelayTaggedUpdateVisitor visitor(&updater);
99  buckets.visit(visitor);
100  kickReads();
101 }
102 
103 void
105 {
106  spec.parse();
107 }
108 
110 
112 {
113  if (!details.tag.length())
114  return new NullDelayId;
115 
116  return new Id(this, details.tag);
117 }
118 
120 {
121  debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket");
122 }
123 
125 {
126  debugs(77, 3, "DelayTaggedBucket::~DelayTaggedBucket");
127 }
128 
129 void
131 {
133  theBucket.stats(entry);
134 }
135 
136 DelayTagged::Id::Id(const DelayTagged::Pointer &aDelayTagged, const SBuf &aTag): theTagged(aDelayTagged)
137 {
138  theBucket = new DelayTaggedBucket(aTag);
140 
141  if (existing) {
142  theBucket = *existing;
143  return;
144  }
145 
148 }
149 
151 {
152  debugs(77, 3, "DelayTagged::Id::~Id");
153 }
154 
155 int
157 {
158  return theBucket->theBucket.bytesWanted(min,max);
159 }
160 
161 void
163 {
164  theBucket->theBucket.bytesIn(qty);
165 }
166 
167 void
169 {
170  theTagged->delayRead(aRead);
171 }
172 
173 #endif
174 
void stats(StoreEntry *sentry) override
Definition: DelayTagged.cc:54
~DelayTagged() override
Definition: DelayTagged.cc:26
void init(DelaySpec const &)
Definition: DelayBucket.cc:47
int bytesWanted(int min, int max) const override
Definition: DelayTagged.cc:156
DelayTaggedUpdateVisitor(DelayTaggedUpdater *u)
Definition: DelayTagged.cc:88
void bytesIn(int qty) override
Definition: DelayTagged.cc:162
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
Definition: store.cc:855
DelayTaggedBucket::Pointer theBucket
Definition: DelayTagged.h:73
Definition: SBuf.h:93
static void deregisterForUpdates(Updateable *)
Definition: delay_pools.cc:515
const A & max(A const &lhs, A const &rhs)
DelayTaggedBucket(const SBuf &aTag)
Definition: DelayTagged.cc:119
DelaySpec spec
Definition: DelayTagged.h:78
C * getRaw() const
Definition: RefCount.h:89
void stats(StoreEntry *sentry, char const *) const
Definition: DelaySpec.cc:23
void parse()
Definition: DelaySpec.cc:42
int restore_bps
Definition: DelaySpec.h:23
RefCount< DelayTagged > theTagged
Definition: DelayTagged.h:72
void stats(StoreEntry *) const
Definition: DelayBucket.cc:20
DelayTaggedStatsVisitor(StoreEntry *se)
Definition: DelayTagged.cc:47
void dump(StoreEntry *) const
Definition: DelaySpec.cc:36
Definition: splay.h:49
void operator()(DelayTaggedBucket::Pointer const &current)
Definition: DelayTagged.cc:48
friend class Id
Definition: DelayTagged.h:76
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:32
static Splay< DelayTaggedBucket::Pointer >::SPLAYFREE DelayTaggedFree
Definition: DelayTagged.cc:24
static void registerForUpdates(Updateable *)
Definition: delay_pools.cc:508
DelayBucket theBucket
Definition: DelayTagged.h:36
~DelayTaggedBucket() override
Definition: DelayTagged.cc:124
Splay< DelayTaggedBucket::Pointer > buckets
Definition: DelayTagged.h:79
void stats(StoreEntry *) const
Definition: DelayTagged.cc:130
~Id() override
Definition: DelayTagged.cc:150
void delayRead(const AsyncCallPointer &) override
Definition: DelayTagged.cc:168
void operator()(DelayTaggedBucket::Pointer const &current)
Definition: DelayTagged.cc:89
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:419
DelayTaggedUpdater * updater
Definition: DelayTagged.cc:87
void parse() override
Definition: DelayTagged.cc:104
const SBuf tag
Definition: DelayTagged.h:37
void update(int incr) override
Definition: DelayTagged.cc:95
DelayIdComposite::Pointer id(CompositeSelectionDetails &) override
Definition: DelayTagged.cc:111
DelayTaggedUpdater(DelaySpec &_spec, int _incr)
Definition: DelayTagged.cc:80
static Splay< DelayTaggedBucket::Pointer >::SPLAYCMP DelayTaggedCmp
Definition: DelayTagged.cc:32
int caseCmp(const SBuf &S, const size_type n) const
shorthand version for case-insensitive compare()
Definition: SBuf.h:287
void dump(StoreEntry *entry) const override
Definition: DelayTagged.cc:74
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:192
const A & min(A const &lhs, A const &rhs)
Id(const RefCount< DelayTagged > &, const SBuf &)
Definition: DelayTagged.cc:136
#define SQUIDSBUFPH
Definition: SBuf.h:31

 

Introduction

Documentation

Support

Miscellaneous