diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-03-26 14:08:18 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-03-26 14:08:18 +0000 |
commit | d1381aef827d328ab80d11e0b9c478ec2b6f2d70 (patch) | |
tree | 3d7bbd4f4c615a442002e5c9c8f17c3ea8e5a493 /src/or/connection_or.c | |
parent | 38c0bb3a99956a0ff2e570bd8f2b900d46741992 (diff) | |
download | tor-d1381aef827d328ab80d11e0b9c478ec2b6f2d70.tar tor-d1381aef827d328ab80d11e0b9c478ec2b6f2d70.tar.gz |
r12652@Kushana: nickm | 2007-03-25 15:01:48 -0400
A surprisingly simple patch to stop reading on edge connections when their circuits get too full, and start again when they empty out. This lets us remove the logic to block begin_dir conns when the corresponding or conns get full: it was already broken by cell queues anyway.
svn:r9905
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 8ebb6b475..ab73d3ea4 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -16,7 +16,6 @@ const char connection_or_c_id[] = static int connection_tls_finish_handshake(or_connection_t *conn); static int connection_or_process_cells_from_inbuf(or_connection_t *conn); -static int connection_or_empty_enough_for_dirserv_data(or_connection_t *conn); /**************************************************************/ @@ -232,21 +231,22 @@ connection_or_process_inbuf(or_connection_t *conn) } } +/**DOCDOC*/ +#define OR_CONN_HIGHWATER (32*1024) + +/**DOCDOC*/ +#define OR_CONN_LOWWATER (16*1024) + /** Called whenever we have flushed some data on an or_conn: add more data * from active circuits. */ int connection_or_flushed_some(or_connection_t *conn) { - if (conn->blocked_dir_connections && - connection_or_empty_enough_for_dirserv_data(conn)) { - connection_dirserv_stop_blocking_all_on_or_conn(conn); - } - if (buf_datalen(conn->_base.outbuf) < 16*1024) { - int n = (32*1024 - buf_datalen(conn->_base.outbuf)) / CELL_NETWORK_SIZE; + size_t datalen = buf_datalen(conn->_base.outbuf); + if (datalen < OR_CONN_LOWWATER) { + int n = (OR_CONN_HIGHWATER - datalen) / CELL_NETWORK_SIZE; while (conn->active_circuits && n > 0) { - int flushed; - log_info(LD_GENERAL, "Loop, n==%d",n); - flushed = connection_or_flush_from_first_active_circuit(conn, 1); + int flushed = connection_or_flush_from_first_active_circuit(conn, 1); n -= flushed; } } @@ -799,32 +799,3 @@ connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn, int reason) return 0; } -/** A high waterlevel for whether to refill this OR connection - * with more directory information, if any is pending. */ -#define DIR_BUF_FULLNESS_THRESHOLD (128*1024) -/** A bottom waterlevel for whether to refill this OR connection - * with more directory information, if any is pending. We don't want - * to make this too low, since we already run the risk of starving - * the pending dir connections if the OR conn is frequently busy with - * other things. */ -#define DIR_BUF_EMPTINESS_THRESHOLD (96*1024) - -/** Return true iff there is so much data waiting to be flushed on <b>conn</b> - * that we should stop writing directory data to it. */ -int -connection_or_too_full_for_dirserv_data(or_connection_t *conn) -{ - return buf_datalen(conn->_base.outbuf) > DIR_BUF_FULLNESS_THRESHOLD; -} - -/** Return true iff there is no longer so much data waiting to be flushed on - * <b>conn</b> that we should not write directory data to it. */ -static int -connection_or_empty_enough_for_dirserv_data(or_connection_t *conn) -{ - /* Note that the threshold to stop writing is a bit higher than the - * threshold to start again: this should (with any luck) keep us from - * flapping about indefinitely. */ - return buf_datalen(conn->_base.outbuf) < DIR_BUF_EMPTINESS_THRESHOLD; -} - |