diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-04-08 03:36:39 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-04-08 03:36:39 +0000 |
commit | 74dc7eedc510d70ea600dd5938f45947a314bc24 (patch) | |
tree | 3c3cd636c2b88314e3adaa7e5b17e096dca09c22 /src/or/connection.c | |
parent | 31c12e265fbd135aba4c335da48ceb5a80f2859e (diff) | |
download | tor-74dc7eedc510d70ea600dd5938f45947a314bc24.tar.gz tor-74dc7eedc510d70ea600dd5938f45947a314bc24.zip |
Add kludgy function to force controllers to flush EVENT_ERR_MSG events.
svn:r4057
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 1775f122e7..c19c9b9dd0 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1265,6 +1265,40 @@ int connection_handle_write(connection_t *conn) { return 0; } +/* DOCDOC */ +void _connection_controller_force_write(connection_t *conn) +{ + /* XXX This is hideous code duplication, but raising it seems a little + * tricky for now. Think more about this one. We only call it for + * EVENT_ERR_MSG, so messing with buckets a little isn't such a big problem. + */ + int result; + tor_assert(conn); + tor_assert(!conn->tls); + tor_assert(conn->type == CONN_TYPE_CONTROL); + if (conn->marked_for_close || conn->s < 0) + return; + + result = flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen); + if (result < 0) { + connection_close_immediate(conn); /* Don't flush; connection is dead. */ + connection_mark_for_close(conn); + return; + } + + if (result > 0 && !is_local_IP(conn->addr)) { /* remember it */ + rep_hist_note_bytes_written(result, time(NULL)); + global_write_bucket -= result; + } + + if (!connection_wants_to_flush(conn)) { /* it's done flushing */ + if (connection_finished_flushing(conn) < 0) { + /* already marked */ + return; + } + } +} + /** Append <b>len</b> bytes of <b>string</b> onto <b>conn</b>'s * outbuf, and ask it to start writing. */ |