diff options
author | Roger Dingledine <arma@torproject.org> | 2003-12-14 06:03:46 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-12-14 06:03:46 +0000 |
commit | 36ea39ec9caa47cd804887655947002eeab71a16 (patch) | |
tree | e8f630101654e0193e168243b106a1030bd29be4 /src/or/connection.c | |
parent | 50e17d633bec55943322bd547003cf3625ce05e1 (diff) | |
download | tor-36ea39ec9caa47cd804887655947002eeab71a16.tar.gz tor-36ea39ec9caa47cd804887655947002eeab71a16.zip |
on hup, close and rebind listener ports too (in case their config has changed)
svn:r926
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index e4aba96208..9ba9f9946a 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -289,6 +289,15 @@ int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_ return 1; } +static void listener_close_if_present(int type) { + connection_t *conn = connection_get_by_type(type); + if (conn) { + close(conn->s); + conn->s = -1; + conn->marked_for_close = 1; + } +} + /* start all connections that should be up but aren't */ int retry_all_connections(void) { @@ -296,19 +305,22 @@ int retry_all_connections(void) { router_retry_connections(); } - if(options.ORPort && !connection_get_by_type(CONN_TYPE_OR_LISTENER)) { + if(options.ORPort) { + listener_close_if_present(CONN_TYPE_OR_LISTENER); if(connection_create_listener(options.ORBindAddress, options.ORPort, CONN_TYPE_OR_LISTENER) < 0) return -1; } - if(options.DirPort && !connection_get_by_type(CONN_TYPE_DIR_LISTENER)) { + if(options.DirPort) { + listener_close_if_present(CONN_TYPE_DIR_LISTENER); if(connection_create_listener(options.DirBindAddress, options.DirPort, CONN_TYPE_DIR_LISTENER) < 0) return -1; } - - if(options.SocksPort && !connection_get_by_type(CONN_TYPE_AP_LISTENER)) { + + if(options.SocksPort) { + listener_close_if_present(CONN_TYPE_AP_LISTENER); if(connection_create_listener(options.SocksBindAddress, options.SocksPort, CONN_TYPE_AP_LISTENER) < 0) return -1; |