Allow hold-open-until-flushed logic to work for bufferevents.

This commit is contained in:
Nick Mathewson 2009-08-08 17:47:47 -07:00
parent ec10c044fb
commit d830eb366a
2 changed files with 10 additions and 2 deletions

View File

@ -2661,14 +2661,17 @@ static void
connection_handle_write_cb(struct bufferevent *bufev, void *arg) connection_handle_write_cb(struct bufferevent *bufev, void *arg)
{ {
connection_t *conn = arg; connection_t *conn = arg;
(void) bufev; struct evbuffer *output;
if (connection_flushed_some(conn)<0) { if (connection_flushed_some(conn)<0) {
connection_mark_for_close(conn); connection_mark_for_close(conn);
return; return;
} }
if (!connection_wants_to_flush(conn)) { output = bufferevent_get_output(bufev);
if (!evbuffer_get_length(output)) {
connection_finished_flushing(conn); connection_finished_flushing(conn);
if (conn->marked_for_close && conn->hold_open_until_flushed)
conn->hold_open_until_flushed = 0;
} }
} }

View File

@ -639,6 +639,11 @@ conn_close_if_marked(int i)
assert_connection_ok(conn, now); assert_connection_ok(conn, now);
/* assert_all_pending_dns_resolves_ok(); */ /* 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); log_debug(LD_NET,"Cleaning up connection (fd %d).",conn->s);
if ((conn->s >= 0 || conn->linked_conn) && connection_wants_to_flush(conn)) { 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 /* s == -1 means it's an incomplete edge connection, or that the socket