mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r17949@catbus: nickm | 2008-02-06 13:21:12 -0500
Fix bandwidth bucked calculations again, I think. Bugfix on 0.1.2.x. Backport candidate. svn:r13406
This commit is contained in:
+13
-7
@@ -1659,13 +1659,19 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
|
||||
int seconds_elapsed, const char *name)
|
||||
{
|
||||
int starting_bucket = *bucket;
|
||||
if (starting_bucket < burst) {
|
||||
int incr = rate*seconds_elapsed;
|
||||
*bucket += incr;
|
||||
if (*bucket > burst || *bucket < starting_bucket) {
|
||||
/* If we overflow the burst, or underflow our starting bucket,
|
||||
* cap the bucket value to burst. */
|
||||
*bucket = burst;
|
||||
if (starting_bucket < burst && seconds_elapsed) {
|
||||
if (((burst - starting_bucket)/seconds_elapsed) < rate) {
|
||||
*bucket = burst; /* We would overflow the bucket; just set it to
|
||||
* the maximum. */
|
||||
} else {
|
||||
int incr = rate*seconds_elapsed;
|
||||
*bucket += incr;
|
||||
if (*bucket > burst || *bucket < starting_bucket) {
|
||||
/* If we overflow the burst, or underflow our starting bucket,
|
||||
* cap the bucket value to burst. */
|
||||
/* XXXX020 this might be redundant now. */
|
||||
*bucket = burst;
|
||||
}
|
||||
}
|
||||
log(LOG_DEBUG, LD_NET,"%s now %d.", name, *bucket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user