MessageBucket.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 {
39  theAggregate->bytesIn(len);
40 }
41 
42 void
44 {
45  fde *F = &fd_table[state->conn->fd];
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.
virtual void reduceBucket(const int len)
Decreases the bucket level.
PF HandleWrite
Definition: forward.h:34
#define fd_table
Definition: fde.h:157
MessageBucket(const int speed, const int initialLevelPercent, const double sizeLimit, MessageDelayPool::Pointer pool)
bool noLimit() const
whether the aggregate bucket has no limit
virtual int quota() override
MessageDelayPool::Pointer theAggregate
Definition: MessageBucket.h:35
virtual void reduceBucket(int len) override
Decreases the bucket level.
bool selectWaiting
is between commSetSelect and commHandleWrite
int level()
current aggregate level
void refillBucket()
Increases the bucket level with the writeSpeedLimit speed.
Comm::ConnectionPointer conn
Definition: IoCallback.h:33
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
Definition: ModDevPoll.cc:225
bool noLimit() const
Whether this bucket will not do bandwidth limiting.
#define COMM_SELECT_WRITE
Definition: defines.h:37
double bucketLevel
how much can be written now
void refillBucket()
Increases the aggregate bucket level with the aggregateRestore speed.
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
Definition: fde.h:49
static uint32 F(uint32 X, uint32 Y, uint32 Z)
Definition: md4.c:46
void bytesIn(int qty)
decreases the aggregate level
virtual void scheduleWrite(Comm::IoCallback *state) override
Will plan another write call.
MessageBucket::Pointer writeQuotaHandler
response write limiter, if configured
Definition: fde.h:121
Details about a particular Comm IO callback event.
Definition: IoCallback.h:29
A const & min(A const &lhs, A const &rhs)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors