diff options
author | Roger Dingledine <arma@torproject.org> | 2005-10-29 18:19:37 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-10-29 18:19:37 +0000 |
commit | bf2be9abd75c2057e2f8f75c0480c2699c6299a5 (patch) | |
tree | a1216182d356b8c126894dc7bc831d4b6ac38be1 /src/or/main.c | |
parent | 862e8a1bd1a1d1f972b94b90bc0bd42a0dd2027b (diff) | |
download | tor-bf2be9abd75c2057e2f8f75c0480c2699c6299a5.tar tor-bf2be9abd75c2057e2f8f75c0480c2699c6299a5.tar.gz |
Do round-robin writes of at most 16 kB per write. This might
be more fair on loaded Tor servers, and it might resolve our
Windows crash bug. It might also slow things down.
svn:r5332
Diffstat (limited to 'src/or/main.c')
-rw-r--r-- | src/or/main.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/or/main.c b/src/or/main.c index 7e155d145..525a81c57 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -439,8 +439,9 @@ conn_close_if_marked(int i) debug(LD_NET,"Cleaning up connection (fd %d).",conn->s); if (conn->s >= 0 && connection_wants_to_flush(conn)) { - /* -1 means it's an incomplete edge connection, or that the socket + /* s == -1 means it's an incomplete edge connection, or that the socket * has already been closed as unflushable. */ + int sz = connection_bucket_write_limit(conn); if (!conn->hold_open_until_flushed) info(LD_NET, "Conn (addr %s, fd %d, type %s, state %d) marked, but wants to flush %d bytes. " @@ -449,14 +450,15 @@ conn_close_if_marked(int i) (int)conn->outbuf_flushlen, conn->marked_for_close_file, conn->marked_for_close); if (connection_speaks_cells(conn)) { if (conn->state == OR_CONN_STATE_OPEN) { - retval = flush_buf_tls(conn->tls, conn->outbuf, &conn->outbuf_flushlen); + retval = flush_buf_tls(conn->tls, conn->outbuf, sz, &conn->outbuf_flushlen); } else retval = -1; /* never flush non-open broken tls connections */ } else { - retval = flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); + retval = flush_buf(conn->s, conn->outbuf, sz, &conn->outbuf_flushlen); } - if (retval >= 0 && - conn->hold_open_until_flushed && connection_wants_to_flush(conn)) { + if (retval >= 0 && /* Technically, we could survive things like + TLS_WANT_WRITE here. But don't bother for now. */ + conn->hold_open_until_flushed && connection_wants_to_flush(conn)) { LOG_FN_CONN(conn, (LOG_INFO,LD_NET,"Holding conn (fd %d) open for more flushing.",conn->s)); /* XXX should we reset timestamp_lastwritten here? */ |