From b35f7dacef6b5e4215dfba9a4088a73421fb103c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 3 May 2005 03:51:20 +0000 Subject: [PATCH] Call tor_free_all instead of connections_free_all after forking svn:r4173 --- src/or/cpuworker.c | 2 +- src/or/dns.c | 2 +- src/or/main.c | 15 +++++++++------ src/or/or.h | 1 + 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 3a1a61a8ea..1f4f4aec1d 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -214,7 +214,7 @@ static int cpuworker_main(void *data) { fd = fdarray[1]; /* this side is ours */ #ifndef TOR_IS_MULTITHREADED tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */ - connection_free_all(); /* so the child doesn't hold the parent's fd's open */ + tor_free_all(1); /* so the child doesn't hold the parent's fd's open */ handle_signals(0); /* ignore interrupts from the keyboard, etc */ #endif tor_free(data); diff --git a/src/or/dns.c b/src/or/dns.c index ff02efc050..805218f68e 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -721,7 +721,7 @@ static int dnsworker_main(void *data) { fd = fdarray[1]; /* this side is ours */ #ifndef TOR_IS_MULTITHREADED tor_close_socket(fdarray[0]); /* this is the side of the socketpair the parent uses */ - connection_free_all(); /* so the child doesn't hold the parent's fd's open */ + connection_free_all(1); /* so the child doesn't hold the parent's fd's open */ handle_signals(0); /* ignore interrupts from the keyboard, etc */ #endif tor_free(data); diff --git a/src/or/main.c b/src/or/main.c index 12e8536aad..1dbc396589 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -40,7 +40,6 @@ static void conn_write_callback(int fd, short event, void *_conn); static void signal_callback(int fd, short events, void *arg); static void second_elapsed_callback(int fd, short event, void *args); static int conn_close_if_marked(int i); -void tor_free_all(void); /********* START VARIABLES **********/ @@ -1227,7 +1226,7 @@ static int tor_init(int argc, char *argv[]) { * * Also valgrind should then report 0 reachable in its * leak report */ -void tor_free_all(void) +void tor_free_all(int postfork) { routerlist_free_current(); free_trusted_dir_servers(); @@ -1242,13 +1241,17 @@ void tor_free_all(void) clear_pending_onions(); circuit_free_all(); connection_free_all(); - config_free_all(); - router_free_all_keys(); + if (!postfork) { + config_free_all(); + router_free_all_keys(); + } tor_tls_free_all(); /* stuff in main.c */ smartlist_free(closeable_connection_lst); - close_logs(); /* free log strings. do this last so logs keep working. */ + if (!postfork) { + close_logs(); /* free log strings. do this last so logs keep working. */ + } } /** Do whatever cleanup is necessary before shutting Tor down. */ @@ -1260,7 +1263,7 @@ void tor_cleanup(void) { unlink(options->PidFile); if (accounting_is_enabled(options)) accounting_record_bandwidth_usage(time(NULL)); - tor_free_all(); /* move tor_free_all back into the ifdef below later. XXX*/ + tor_free_all(0); /* move tor_free_all back into the ifdef below later. XXX*/ crypto_global_cleanup(); #ifdef USE_DMALLOC dmalloc_log_unfreed(); diff --git a/src/or/or.h b/src/or/or.h index a83907d6ed..f778daf72f 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1543,6 +1543,7 @@ void directory_has_arrived(time_t now, char *identity_digest); int control_signal_act(int the_signal); void handle_signals(int is_parent); void tor_cleanup(void); +void tor_free_all(int postfork); int tor_main(int argc, char *argv[]); -- 2.11.4.GIT