diff options
author | Roger Dingledine <arma@torproject.org> | 2006-02-04 08:58:51 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2006-02-04 08:58:51 +0000 |
commit | 640c555f02a97dd253d96e0c0bf7ed3051a32c58 (patch) | |
tree | f14e6ad96150b63480a27ff730cca2e44f2d0d2f | |
parent | 032a01ef6451f485c909001a1893494507b1f8f2 (diff) | |
download | tor-640c555f02a97dd253d96e0c0bf7ed3051a32c58.tar.gz tor-640c555f02a97dd253d96e0c0bf7ed3051a32c58.zip |
Fix a major load balance bug: we were round-robining in 16 KB chunks, and
servers with bandwidthrate of 20 KB, while downloading a 600 KB directory,
would starve their other connections. Now we try to be a bit more fair.
svn:r5906
-rw-r--r-- | src/or/connection.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 6f4482e932..7c93aef4de 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -988,13 +988,18 @@ static int connection_bucket_read_limit(connection_t *conn) { int at_most; - - /* do a rudimentary round-robin so one circuit can't hog a connection */ - if (connection_speaks_cells(conn)) { - at_most = 32*(CELL_NETWORK_SIZE); - } else { - at_most = 32*(RELAY_PAYLOAD_SIZE); - } + int base = connection_speaks_cells(conn) ? + CELL_NETWORK_SIZE : RELAY_PAYLOAD_SIZE; + + /* Do a rudimentary round-robin so one circuit can't hog a connection. + * Pick at most 32 cells, at least 4 cells if possible, and if we're in + * the middle pick 1/8 of the available bandwidth. */ + at_most = global_read_bucket / 8; + at_most -= (at_most % base); /* round down */ + if (at_most > 32*base) /* 16 KB */ + at_most = 32*base; + else if (at_most < 4*base) /* 2 KB */ + at_most = 4*base; if (at_most > global_read_bucket) at_most = global_read_bucket; |