]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/MessageBucket.cc
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
12 #include "comm/Connection.h"
13 #include "DelayPools.h"
15 #include "MessageBucket.h"
17 MessageBucket::MessageBucket(const int speed
, const int initialLevelPercent
,
18 const double sizeLimit
, MessageDelayPool::Pointer pool
) :
19 BandwidthBucket(speed
, initialLevelPercent
, sizeLimit
),
23 MessageBucket::quota()
26 theAggregate
->refillBucket();
27 if (theAggregate
->noLimit())
30 return theAggregate
->level();
32 return min(bucketLevel
, static_cast<double>(theAggregate
->level()));
36 MessageBucket::reduceBucket(int len
)
38 BandwidthBucket::reduceBucket(len
);
39 theAggregate
->bytesIn(len
);
43 MessageBucket::scheduleWrite(Comm::IoCallback
*state
)
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()
49 SetSelect(state
->conn
->fd
, COMM_SELECT_WRITE
, Comm::HandleWrite
, state
, 0);
53 #endif /* USE_DELAY_POOLS */