MessageBucket.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#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
17MessageBucket::MessageBucket(const int speed, const int initialLevelPercent,
18 const double sizeLimit, MessageDelayPool::Pointer pool) :
19 BandwidthBucket(speed, initialLevelPercent, sizeLimit),
20 theAggregate(pool) {}
21
22int
24{
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
35void
37{
40}
41
42void
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
Base class for Squid-to-client bandwidth limiting.
bool noLimit() const
Whether this bucket will not do bandwidth limiting.
double bucketLevel
how much can be written now
void refillBucket()
Increases the bucket level with the writeSpeedLimit speed.
virtual void reduceBucket(const int len)
Decreases the bucket level.
Details about a particular Comm IO callback event.
Definition: IoCallback.h:30
Comm::ConnectionPointer conn
Definition: IoCallback.h:33
MessageDelayPool::Pointer theAggregate
Definition: MessageBucket.h:35
void reduceBucket(int len) override
Decreases the bucket level.
MessageBucket(const int speed, const int initialLevelPercent, const double sizeLimit, MessageDelayPool::Pointer pool)
int quota() override
void scheduleWrite(Comm::IoCallback *state) override
Will plan another write call.
bool noLimit() const
whether the aggregate bucket has no limit
void refillBucket()
Increases the aggregate bucket level with the aggregateRestore speed.
int level()
current aggregate level
void bytesIn(int qty)
decreases the aggregate level
Definition: fde.h:52
A const & min(A const &lhs, A const &rhs)
#define COMM_SELECT_WRITE
Definition: defines.h:25
#define fd_table
Definition: fde.h:189
static uint32 F(uint32 X, uint32 Y, uint32 Z)
Definition: md4.c:46
PF HandleWrite
Definition: forward.h:33
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
Definition: ModDevPoll.cc:223

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors