MessageBucket.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2020 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 
11 #if USE_DELAY_POOLS
12 #include "comm/Connection.h"
13 #include "DelayPools.h"
14 #include "fde.h"
15 #include "MessageBucket.h"
16 
17 MessageBucket::MessageBucket(const int speed, const int initialLevelPercent,
18  const double sizeLimit, MessageDelayPool::Pointer pool) :
19  BandwidthBucket(speed, initialLevelPercent, sizeLimit),
20  theAggregate(pool) {}
21 
22 int
24 {
25  refillBucket();
27  if (theAggregate->noLimit())
28  return bucketLevel;
29  else if (noLimit())
30  return theAggregate->level();
31  else
32  return min(bucketLevel, static_cast<double>(theAggregate->level()));
33 }
34 
35 void
37 {
40 }
41 
42 void
44 {
45  fde *F = &fd_table[state->conn->fd];
46  if (!F->writeQuotaHandler->selectWaiting) {
47  F->writeQuotaHandler->selectWaiting = true;
48  // message delay pools limit this write; see checkTimeouts()
50  }
51 }
52 
53 #endif /* USE_DELAY_POOLS */
54 
bool noLimit() const
Whether this bucket will not do bandwidth limiting.
void refillBucket()
Increases the aggregate bucket level with the aggregateRestore speed.
void bytesIn(int qty)
decreases the aggregate level
virtual void reduceBucket(int len) override
Decreases the bucket level.
static uint32 F(uint32 X, uint32 Y, uint32 Z)
Definition: md4.c:46
MessageDelayPool::Pointer theAggregate
Definition: MessageBucket.h:35
Definition: fde.h:51
virtual int quota() override
virtual void scheduleWrite(Comm::IoCallback *state) override
Will plan another write call.
Comm::ConnectionPointer conn
Definition: IoCallback.h:33
Details about a particular Comm IO callback event.
Definition: IoCallback.h:29
MessageBucket(const int speed, const int initialLevelPercent, const double sizeLimit, MessageDelayPool::Pointer pool)
virtual void reduceBucket(const int len)
Decreases the bucket level.
bool noLimit() const
whether the aggregate bucket has no limit
Base class for Squid-to-client bandwidth limiting.
int level()
current aggregate level
#define fd_table
Definition: fde.h:189
void refillBucket()
Increases the bucket level with the writeSpeedLimit speed.
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
Definition: ModDevPoll.cc:225
double bucketLevel
how much can be written now
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
PF HandleWrite
Definition: forward.h:32
const A & min(A const &lhs, A const &rhs)
#define COMM_SELECT_WRITE
Definition: defines.h:37

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors