summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-08-08 17:47:47 -0700
committerNick Mathewson <nickm@torproject.org>2010-09-27 12:29:43 -0400
commitd830eb366ab037c820b138cfbb8f4bd66986bf42 (patch)
tree07215f942b87e7dcf460f891b624c350982989cc /src/or
parentec10c044fb3e7b4865a7e9082c5353876e40915f (diff)
downloadtor-d830eb366ab037c820b138cfbb8f4bd66986bf42.tar.gz
tor-d830eb366ab037c820b138cfbb8f4bd66986bf42.zip
Allow hold-open-until-flushed logic to work for bufferevents.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c7
-rw-r--r--src/or/main.c5
2 files changed, 10 insertions, 2 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index ff5c4c04ae..6665809bc2 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -2661,14 +2661,17 @@ static void
connection_handle_write_cb(struct bufferevent *bufev, void *arg)
{
connection_t *conn = arg;
- (void) bufev;
+ struct evbuffer *output;
if (connection_flushed_some(conn)<0) {
connection_mark_for_close(conn);
return;
}
- if (!connection_wants_to_flush(conn)) {
+ output = bufferevent_get_output(bufev);
+ if (!evbuffer_get_length(output)) {
connection_finished_flushing(conn);
+ if (conn->marked_for_close && conn->hold_open_until_flushed)
+ conn->hold_open_until_flushed = 0;
}
}
diff --git a/src/or/main.c b/src/or/main.c
index 54c78c32dc..b8867852c7 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -639,6 +639,11 @@ conn_close_if_marked(int i)
assert_connection_ok(conn, now);
/* assert_all_pending_dns_resolves_ok(); */
+#ifdef USE_BUFFEREVENTS
+ if (conn->bufev && conn->hold_open_until_flushed)
+ return 0;
+#endif
+
log_debug(LD_NET,"Cleaning up connection (fd %d).",conn->s);
if ((conn->s >= 0 || conn->linked_conn) && connection_wants_to_flush(conn)) {
/* s == -1 means it's an incomplete edge connection, or that the socket