diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-01-27 08:55:06 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-01-27 08:55:06 +0000 |
commit | 9984cad6e86d65f4685fd1283bf1f1b4a4602f22 (patch) | |
tree | ce97ea208a1650414535881a16c5dce4dab40f87 /src/or/connection_or.c | |
parent | 2525c44d176feb5227910ccc63e39622774086dc (diff) | |
download | tor-9984cad6e86d65f4685fd1283bf1f1b4a4602f22.tar tor-9984cad6e86d65f4685fd1283bf1f1b4a4602f22.tar.gz |
r11552@catbus: nickm | 2007-01-27 03:55:02 -0500
This one is a little tricky. Our BEGIN_DIR implementation has a
problem: the dirserv conns will decide they can flush all their data
immediately, since the edge_conns will read greedily.
For our 0.1.2 workaround, we track which or_conn a bridged dirserv
conn is attached to, and stop writing when its outbuf is too full, and
start writing again when the or_conn's outbuf empties out a little.
This requires a bit of pointer management. Let's hope it works.
svn:r9432
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 295a060fe..036a1b1dd 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -21,6 +21,7 @@ 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); /**************************************************************/ @@ -224,6 +225,17 @@ connection_or_process_inbuf(or_connection_t *conn) } } +/** Called whenever we have flushed some data on an or_conn. */ +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); + } + return 0; +} + /** Connection <b>conn</b> has finished writing and has no bytes left on * its outbuf. * @@ -798,3 +810,25 @@ connection_or_count_pending_circs(or_connection_t *or_conn) return cnt; } +#define BUF_FULLNESS_THRESHOLD (128*1024) +#define 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 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) < BUF_EMPTINESS_THRESHOLD; +} + |