summaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-12-14 06:03:46 +0000
committerRoger Dingledine <arma@torproject.org>2003-12-14 06:03:46 +0000
commit36ea39ec9caa47cd804887655947002eeab71a16 (patch)
treee8f630101654e0193e168243b106a1030bd29be4 /src/or/connection.c
parent50e17d633bec55943322bd547003cf3625ce05e1 (diff)
downloadtor-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.c20
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;