[or-cvs] Call tor_free_all instead of connections_free_all after for...

Nick Mathewson nickm at seul.org
Tue May 3 03:51:22 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv13721

Modified Files:
	cpuworker.c dns.c main.c or.h 
Log Message:
Call tor_free_all instead of connections_free_all after forking

Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/cpuworker.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cpuworker.c	2 May 2005 22:35:18 -0000	1.77
+++ cpuworker.c	3 May 2005 03:51:19 -0000	1.78
@@ -214,7 +214,7 @@
   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);

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- dns.c	26 Apr 2005 20:05:15 -0000	1.150
+++ dns.c	3 May 2005 03:51:19 -0000	1.151
@@ -721,7 +721,7 @@
   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);

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.490
retrieving revision 1.491
diff -u -d -r1.490 -r1.491
--- main.c	2 May 2005 23:17:08 -0000	1.490
+++ main.c	3 May 2005 03:51:19 -0000	1.491
@@ -40,7 +40,6 @@
 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 @@
  *
  * 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 @@
   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 @@
     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();

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.601
retrieving revision 1.602
diff -u -d -r1.601 -r1.602
--- or.h	2 May 2005 23:32:23 -0000	1.601
+++ or.h	3 May 2005 03:51:20 -0000	1.602
@@ -1543,6 +1543,7 @@
 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[]);
 



More information about the tor-commits mailing list