From a5544e589d1724fc2765b277da736bbb2a9a8299 Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Tue, 15 Apr 2014 20:19:39 -0700 Subject: [PATCH 1/2] Close orconns correctly through channels when setting DisableNetwork to 1 --- changes/bug11306 | 4 ++++ src/or/connection.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 changes/bug11306 diff --git a/changes/bug11306 b/changes/bug11306 new file mode 100644 index 0000000000..bf8ea40114 --- /dev/null +++ b/changes/bug11306 @@ -0,0 +1,4 @@ + o Bugfixes: + - When closing all connections on setting DisableNetwork to 1, use + connection_or_close_normally() rather than closing orconns out from + under the channel layer. Fixes bug #11306. diff --git a/src/or/connection.c b/src/or/connection.c index 1be4c45dd7..0c61b0d616 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -2359,6 +2359,20 @@ connection_mark_all_noncontrol_connections(void) connection_mark_unattached_ap(TO_ENTRY_CONN(conn), END_STREAM_REASON_HIBERNATING); break; + case CONN_TYPE_OR: + { + or_connection_t *orconn = TO_OR_CONN(conn); + if (orconn->chan) { + connection_or_close_normally(orconn, 0); + } else { + /* + * There should have been one, but mark for close and hope + * for the best.. + */ + connection_mark_for_close(conn); + } + } + break; default: connection_mark_for_close(conn); break; From f36e93206a20b37321b372802032d3dec481856d Mon Sep 17 00:00:00 2001 From: Andrea Shepard Date: Tue, 15 Apr 2014 20:35:31 -0700 Subject: [PATCH 2/2] Avoid redundant calls to connection_mark_for_close() on listeners when setting DisableNetwork to 1 --- src/or/config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/or/config.c b/src/or/config.c index ca99d014fc..3089c6f51b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1178,10 +1178,13 @@ options_act_reversible(const or_options_t *old_options, char **msg) SMARTLIST_FOREACH(replaced_listeners, connection_t *, conn, { + int marked = conn->marked_for_close; log_notice(LD_NET, "Closing old %s on %s:%d", conn_type_to_string(conn->type), conn->address, conn->port); connection_close_immediate(conn); - connection_mark_for_close(conn); + if (!marked) { + connection_mark_for_close(conn); + } }); goto done;