From fa89c9f0868d4902e0298ac9ef23e521633f933b Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Tue, 23 Jun 2009 23:09:27 -0400 Subject: [PATCH 1/3] Flush long replies over control port on QUIT Marks the control port connection for flushing before closing when the QUIT command is issued. This allows a QUIT to be issued during a long reply over the control port, flushing the reply and then closing the connection. Fixes bug 1015. --- src/or/control.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/or/control.c b/src/or/control.c index 486ccc4c75..98c6aa458c 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2892,6 +2892,7 @@ connection_control_process_inbuf(control_connection_t *conn) if (!strcasecmp(conn->incoming_cmd, "QUIT")) { connection_write_str_to_buf("250 closing connection\r\n", conn); connection_mark_for_close(TO_CONN(conn)); + conn->_base.hold_open_until_flushed = 1; return 0; } From d3087389196b585ab4e0b5ee64fc36b16f071eef Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Tue, 23 Jun 2009 23:14:44 -0400 Subject: [PATCH 2/3] Ignore control port commands after a QUIT When a QUIT has been issued on a control port connection, then ignore further commands on that port. This fixes bug 1016. --- src/or/control.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/or/control.c b/src/or/control.c index 98c6aa458c..90c99fd51a 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2888,7 +2888,12 @@ connection_control_process_inbuf(control_connection_t *conn) --data_len; } - /* Quit is always valid. */ + /* If the connection is already closing, ignore further commands */ + if (TO_CONN(conn)->marked_for_close) { + return 0; + } + + /* Otherwise, Quit is always valid. */ if (!strcasecmp(conn->incoming_cmd, "QUIT")) { connection_write_str_to_buf("250 closing connection\r\n", conn); connection_mark_for_close(TO_CONN(conn)); From cea85b4066f8f279f8de2563a7830b136fdc059f Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Wed, 24 Jun 2009 00:06:53 -0400 Subject: [PATCH 3/3] Added ChangeLog entry for control port fix --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index a150710767..dba7e36dbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,16 @@ Changes in version 0.2.1.17-?? - 2009-??-?? authorities start doing active measurements. Implements more of proposal 141. + o Minor bugfixes (on 0.2.0.x): + - Control port would close the connection before flushing long + replies, such as the network consensus, if a QUIT command was + issued before the reply had completed. Now, the control port + flushes all pending replies before closing the connection. + Also fixed a condition where a QUIT command issued after a + malformed or rejected AUTHENTICATE command, but before the + connection was closed would result in a warning in the logger + for a doubly-closed connection. Fixes bugs 1015 and 1016. + Changes in version 0.2.1.16-rc - 2009-06-20 o Security fixes: