Commit 502879e0 authored by Peter Palfrader's avatar Peter Palfrader
Browse files

Remove force flag from retry_all_listeners() and retry_listeners(). It always was 0.

svn:r10486
parent 6faa9e26
......@@ -830,7 +830,7 @@ options_act_reversible(or_options_t *old_options, char **msg)
/* Launch the listeners. (We do this before we setuid, so we can bind to
* ports under 1024.) */
if (retry_all_listeners(0, replaced_listeners, new_listeners) < 0) {
if (retry_all_listeners(replaced_listeners, new_listeners) < 0) {
*msg = tor_strdup("Failed to bind one of the listener ports.");
goto rollback;
}
......
......@@ -995,17 +995,16 @@ connection_connect(connection_t *conn, const char *address,
* connection binding to each one. Otherwise, create a single
* connection binding to the address <b>default_addr</b>.)
*
* If <b>force</b> is true, close and re-open all listener connections.
* Otherwise, only relaunch the listeners of this type if the number of
* existing connections is not as configured (e.g., because one died),
* or if the existing connections do not match those configured.
* Only relaunch the listeners of this type if the number of existing
* connections is not as configured (e.g., because one died), or if the
* existing connections do not match those configured.
*
* Add all old conns that should be closed to <b>replaced_conns</b>.
* Add all new connections to <b>new_conns</b>.
*/
static int
retry_listeners(int type, config_line_t *cfg,
int port_option, const char *default_addr, int force,
int port_option, const char *default_addr,
smartlist_t *replaced_conns,
smartlist_t *new_conns,
int never_open_conns)
......@@ -1039,15 +1038,6 @@ retry_listeners(int type, config_line_t *cfg,
{
if (conn->type != type || conn->marked_for_close)
continue;
if (force) {
/* It's a listener, and we're relaunching all listeners of this
* type. Close this one. */
log_notice(LD_NET, "Force-closing listener %s on %s:%d",
conn_type_to_string(type), conn->address, conn->port);
connection_close_immediate(conn);
connection_mark_for_close(conn);
continue;
}
/* Okay, so this is a listener. Is it configured? */
line = NULL;
SMARTLIST_FOREACH(launch, config_line_t *, wanted,
......@@ -1110,47 +1100,45 @@ retry_listeners(int type, config_line_t *cfg,
return r;
}
/** (Re)launch listeners for each port you should have open. If
* <b>force</b> is true, close and relaunch all listeners. If <b>force</b>
* is false, then only relaunch listeners when we have the wrong number of
* connections for a given type.
/** (Re)launch listeners for each port you should have open. Only relaunch
* listeners when we have the wrong number of connections for a given type.
*
* Add all old conns that should be closed to <b>replaced_conns</b>.
* Add all new connections to <b>new_conns</b>.
*/
int
retry_all_listeners(int force, smartlist_t *replaced_conns,
retry_all_listeners(smartlist_t *replaced_conns,
smartlist_t *new_conns)
{
or_options_t *options = get_options();
if (retry_listeners(CONN_TYPE_OR_LISTENER, options->ORListenAddress,
options->ORPort, "0.0.0.0", force,
options->ORPort, "0.0.0.0",
replaced_conns, new_conns, options->ClientOnly)<0)
return -1;
if (retry_listeners(CONN_TYPE_DIR_LISTENER, options->DirListenAddress,
options->DirPort, "0.0.0.0", force,
options->DirPort, "0.0.0.0",
replaced_conns, new_conns, 0)<0)
return -1;
if (retry_listeners(CONN_TYPE_AP_LISTENER, options->SocksListenAddress,
options->SocksPort, "127.0.0.1", force,
options->SocksPort, "127.0.0.1",
replaced_conns, new_conns, 0)<0)
return -1;
if (retry_listeners(CONN_TYPE_AP_TRANS_LISTENER, options->TransListenAddress,
options->TransPort, "127.0.0.1", force,
options->TransPort, "127.0.0.1",
replaced_conns, new_conns, 0)<0)
return -1;
if (retry_listeners(CONN_TYPE_AP_NATD_LISTENER, options->NatdListenAddress,
options->NatdPort, "127.0.0.1", force,
options->NatdPort, "127.0.0.1",
replaced_conns, new_conns, 0)<0)
return -1;
if (retry_listeners(CONN_TYPE_AP_DNS_LISTENER, options->DNSListenAddress,
options->DNSPort, "127.0.0.1", force,
options->DNSPort, "127.0.0.1",
replaced_conns, new_conns, 0)<0)
return -1;
if (retry_listeners(CONN_TYPE_CONTROL_LISTENER,
options->ControlListenAddress,
options->ControlPort, "127.0.0.1", force,
options->ControlPort, "127.0.0.1",
replaced_conns, new_conns, 0)<0)
return -1;
......
......@@ -1012,7 +1012,7 @@ run_scheduled_events(time_t now)
/** 3d. And every 60 seconds, we relaunch listeners if any died. */
if (!we_are_hibernating() && time_to_check_listeners < now) {
/* 0 means "only launch the ones that died." */
retry_all_listeners(0, NULL, NULL);
retry_all_listeners(NULL, NULL);
time_to_check_listeners = now+60;
}
......
......@@ -2341,7 +2341,7 @@ void connection_expire_held_open(void);
int connection_connect(connection_t *conn, const char *address, uint32_t addr,
uint16_t port);
int retry_all_listeners(int force, smartlist_t *replaced_conns,
int retry_all_listeners(smartlist_t *replaced_conns,
smartlist_t *new_conns);
int connection_bucket_write_limit(connection_t *conn);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment