From 309961138b1ebfa78e0f2b6201e06bae64c57e0d Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Mon, 27 Aug 2018 01:07:01 +0000 Subject: [PATCH 1/2] core/mainloop: fix documentation of connection_handle_write_impl() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inaccurate since ​d9746bd468f551d1ada57d962b20eddd15256ce9. --- src/core/mainloop/connection.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index ed789d5208..95213f5505 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -3762,9 +3762,9 @@ update_send_buffer_size(tor_socket_t sock) /** Try to flush more bytes onto conn-\>s. * - * This function gets called either from conn_write_callback() in main.c - * when libevent tells us that conn wants to write, or below - * from connection_buf_add() when an entire TLS record is ready. + * This function is called in connection_handle_write(), which gets + * called from conn_write_callback() in main.c when libevent tells us + * that conn wants to write. * * Update conn-\>timestamp_last_write_allowed to now, and call flush_buf * or flush_buf_tls appropriately. If it succeeds and there are no more From 0cd72a28339e829443f142743bbc1bd8ede0fbde Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Mon, 27 Aug 2018 01:32:34 +0000 Subject: [PATCH 2/2] core/mainloop: more comments documenting connection.c --- src/core/mainloop/connection.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index 95213f5505..a0902f5164 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -3571,7 +3571,8 @@ connection_buf_read_from_socket(connection_t *conn, ssize_t *max_to_read, * waiting for a TLS renegotiation, the renegotiation started, and * SSL_read returned WANTWRITE. But now SSL_read is saying WANTREAD * again. Stop waiting for write events now, or else we'll - * busy-loop until data arrives for us to read. */ + * busy-loop until data arrives for us to read. + * XXX: remove this when v2 handshakes support is dropped. */ connection_stop_writing(conn); if (!connection_is_reading(conn)) connection_start_reading(conn); @@ -4028,6 +4029,9 @@ connection_handle_write(connection_t *conn, int force) { int res; update_current_time(time(NULL)); + /* connection_handle_write_impl() might call connection_handle_read() + * if we're in the middle of a v2 handshake, in which case it needs this + * flag set. */ conn->in_connection_handle_write = 1; res = connection_handle_write_impl(conn, force); conn->in_connection_handle_write = 0;