From 36ea39ec9caa47cd804887655947002eeab71a16 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sun, 14 Dec 2003 06:03:46 +0000 Subject: [PATCH] on hup, close and rebind listener ports too (in case their config has changed) svn:r926 --- src/or/connection.c | 20 ++++++++++++++++---- src/or/cpuworker.c | 2 +- src/or/dirserv.c | 12 +++++------- src/or/main.c | 5 +++-- 4 files changed, 25 insertions(+), 14 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; diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 2ade1ae2d0..c964115f90 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -58,7 +58,7 @@ int connection_cpu_process_inbuf(connection_t *conn) { assert(conn && conn->type == CONN_TYPE_CPUWORKER); if(conn->inbuf_reached_eof) { - log_fn(LOG_WARN,"Read eof. Worker dying."); + log_fn(LOG_WARN,"Read eof. Worker has died."); if(conn->state != CPUWORKER_STATE_IDLE) { /* the circ associated with this cpuworker will have to wait until * it gets culled in run_connection_housekeeping(), since we have diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 4db989b6b0..8dc4de0080 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -52,7 +52,7 @@ dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk) } /* return 0 on success, -1 on failure */ -int +int dirserv_parse_fingerprint_file(const char *fname) { FILE *file; @@ -172,7 +172,7 @@ static void free_descriptor_entry(descriptor_entry_t *desc) free(desc); } -void +void dirserv_free_descriptors() { int i; @@ -311,7 +311,7 @@ dirserv_init_from_directory_string(const char *dir) return 0; } -static int +static int list_running_servers(char **nicknames_out) { char *nickname_lst[MAX_ROUTERS_IN_DIR]; @@ -323,7 +323,7 @@ list_running_servers(char **nicknames_out) int length; *nicknames_out = NULL; nickname_lst[n++] = options.Nickname; - + get_connection_array(&connection_array, &n_conns); for (i = 0; i