diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-03-26 14:07:59 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-03-26 14:07:59 +0000 |
commit | 38c0bb3a99956a0ff2e570bd8f2b900d46741992 (patch) | |
tree | 9a447e7b431abdc819d3ba1f30755f5b40678c79 /src/or/connection_or.c | |
parent | 6e51bdd5e4d5ab39fc1dca12e468b9a1c573cc1b (diff) | |
download | tor-38c0bb3a99956a0ff2e570bd8f2b900d46741992.tar.gz tor-38c0bb3a99956a0ff2e570bd8f2b900d46741992.zip |
r12651@Kushana: nickm | 2007-03-24 18:26:42 -0400
Initial version of circuit-based cell queues. Instead of hammering or_conns with piles of cells, queue cells on their corresponding circuits, and append them to the or_conn as needed. This seems to work so far, but needs a bit more work. This will break the memory-use-limitation patch for begin_dir conns: the solution will be a fun but fiddly.
svn:r9904
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index d5874f6aa6..8ebb6b4753 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -232,7 +232,8 @@ connection_or_process_inbuf(or_connection_t *conn) } } -/** Called whenever we have flushed some data on an or_conn. */ +/** 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) { @@ -240,6 +241,15 @@ connection_or_flushed_some(or_connection_t *conn) 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; + 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); + n -= flushed; + } + } return 0; } @@ -784,26 +794,27 @@ connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn, int reason) cell.command = CELL_DESTROY; cell.payload[0] = (uint8_t) reason; log_debug(LD_OR,"Sending destroy (circID %d).", circ_id); + /* XXXX clear the rest of the cell queue on the circuit. {cells} */ connection_or_write_cell_to_buf(&cell, conn); return 0; } /** A high waterlevel for whether to refill this OR connection * with more directory information, if any is pending. */ -#define BUF_FULLNESS_THRESHOLD (128*1024) +#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 BUF_EMPTINESS_THRESHOLD (96*1024) +#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) > BUF_FULLNESS_THRESHOLD; + 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 @@ -814,6 +825,6 @@ 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) < BUF_EMPTINESS_THRESHOLD; + return buf_datalen(conn->_base.outbuf) < DIR_BUF_EMPTINESS_THRESHOLD; } |