mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
break out the big guns: reject dir requests much more
aggressively. my vidalia bandwidth graph, when rate limiting to 32kB/s, has the "write" line constantly at 32kB. I can't imagine what's going on with the relay latency but it can't be good. svn:r9366
This commit is contained in:
parent
8662f18102
commit
cb472fc550
@ -1099,6 +1099,8 @@ retry_all_listeners(int force, smartlist_t *replaced_conns,
|
||||
|
||||
extern int global_read_bucket, global_write_bucket;
|
||||
|
||||
static int global_write_bucket_empty_last_second = 0;
|
||||
|
||||
static int
|
||||
connection_bucket_round_robin(int base, int priority,
|
||||
int global_bucket, int conn_bucket)
|
||||
@ -1184,6 +1186,9 @@ global_write_bucket_low(size_t attempt, int priority)
|
||||
if (global_write_bucket < (int)attempt)
|
||||
return 1; /* not enough space no matter the priority */
|
||||
|
||||
if (global_write_bucket_empty_last_second)
|
||||
return 1; /* we're already hitting our limits, no more please */
|
||||
|
||||
if (priority == 1) { /* old-style v1 query */
|
||||
/* Could we handle *two* of these requests within the next two seconds? */
|
||||
int64_t can_write = (int64_t)global_write_bucket
|
||||
@ -1279,6 +1284,7 @@ connection_bucket_refill(int seconds_elapsed)
|
||||
log(LOG_DEBUG, LD_NET,"global_read_bucket now %d.", global_read_bucket);
|
||||
}
|
||||
if (global_write_bucket < (int)options->BandwidthBurst) {
|
||||
global_write_bucket_empty_last_second = global_write_bucket == 0;
|
||||
global_write_bucket += (int)options->BandwidthRate*seconds_elapsed;
|
||||
if (global_write_bucket > (int)options->BandwidthBurst)
|
||||
global_write_bucket = (int)options->BandwidthBurst;
|
||||
|
Loading…
Reference in New Issue
Block a user