From 074bf72a2cb9e641468b9ef92a8b16c7f0e2f00a Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 18 Apr 2012 23:32:02 -0400 Subject: If DisableNetwork, don't even try to open non-controller listeners Fix for 5604; bugfix on 0.2.3.9-alpha, which introduced DisableNetwork. --- src/or/connection.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/or/connection.c') diff --git a/src/or/connection.c b/src/or/connection.c index 1c034c655..642ee6e95 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1812,12 +1812,20 @@ connection_read_proxy_handshake(connection_t *conn) static int retry_listener_ports(smartlist_t *old_conns, const smartlist_t *ports, - smartlist_t *new_conns) + smartlist_t *new_conns, + int close_all_noncontrol) { smartlist_t *launch = smartlist_new(); int r = 0; - smartlist_add_all(launch, ports); + if (close_all_noncontrol) { + SMARTLIST_FOREACH(ports, port_cfg_t *, p, { + if (p->type == CONN_TYPE_CONTROL_LISTENER) + smartlist_add(launch, p); + }); + } else { + smartlist_add_all(launch, ports); + } /* Iterate through old_conns, comparing it to launch: remove from both lists * each pair of elements that corresponds to the same port. */ @@ -1920,7 +1928,7 @@ retry_listener_ports(smartlist_t *old_conns, */ int retry_all_listeners(smartlist_t *replaced_conns, - smartlist_t *new_conns) + smartlist_t *new_conns, int close_all_noncontrol) { smartlist_t *listeners = smartlist_new(); const or_options_t *options = get_options(); @@ -1935,7 +1943,8 @@ retry_all_listeners(smartlist_t *replaced_conns, if (retry_listener_ports(listeners, get_configured_ports(), - new_conns) < 0) + new_conns, + close_all_noncontrol) < 0) retval = -1; /* Any members that were still in 'listeners' don't correspond to -- cgit v1.2.3 From d7e4777791bbaa93f82b98c2529450794b9e8a3f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 30 May 2012 16:53:31 -0400 Subject: Add a little documentation for the bug5604 fix --- src/or/connection.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/or/connection.c') diff --git a/src/or/connection.c b/src/or/connection.c index 642ee6e95..242276538 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1807,18 +1807,21 @@ connection_read_proxy_handshake(connection_t *conn) * entry in ports. Add to new_conns new every connection we * launch. * + * If control_listeners_only is true, then we only open control + * listeners, and we do not remove any noncontrol listeners from old_conns. + * * Return 0 on success, -1 on failure. **/ static int retry_listener_ports(smartlist_t *old_conns, const smartlist_t *ports, smartlist_t *new_conns, - int close_all_noncontrol) + int control_listeners_only) { smartlist_t *launch = smartlist_new(); int r = 0; - if (close_all_noncontrol) { + if (control_listeners_only) { SMARTLIST_FOREACH(ports, port_cfg_t *, p, { if (p->type == CONN_TYPE_CONTROL_LISTENER) smartlist_add(launch, p); @@ -1925,6 +1928,9 @@ retry_listener_ports(smartlist_t *old_conns, * * Add all old conns that should be closed to replaced_conns. * Add all new connections to new_conns. + * + * If close_all_noncontrol is true, then we only open control + * listeners, and we close all other listeners. */ int retry_all_listeners(smartlist_t *replaced_conns, -- cgit v1.2.3