Squid Web Cache master
Loading...
Searching...
No Matches
MessageBucket.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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
41
42void
44{
45 fde *F = &fd_table[state->conn->fd];
48 // message delay pools limit this write; see checkTimeouts()
49 SetSelect(state->conn->fd, COMM_SELECT_WRITE, Comm::HandleWrite, state, 0);
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.
bool selectWaiting
is between commSetSelect and commHandleWrite
Details about a particular Comm IO callback event.
Definition IoCallback.h:30
Comm::ConnectionPointer conn
Definition IoCallback.h:33
MessageDelayPool::Pointer theAggregate
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
MessageBucket::Pointer writeQuotaHandler
response write limiter, if configured
Definition fde.h:144
A const & min(A const &lhs, A const &rhs)
#define COMM_SELECT_WRITE
Definition defines.h:25
#define fd_table
Definition fde.h:189
PF HandleWrite
Definition forward.h:33