[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r10837: free some more memory on exit (in tor/trunk/src: common or)



Author: arma
Date: 2007-07-16 00:33:47 -0400 (Mon, 16 Jul 2007)
New Revision: 10837

Modified:
   tor/trunk/src/common/log.c
   tor/trunk/src/common/log.h
   tor/trunk/src/or/main.c
Log:
free some more memory on exit


Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c	2007-07-16 03:40:25 UTC (rev 10836)
+++ tor/trunk/src/common/log.c	2007-07-16 04:33:47 UTC (rev 10837)
@@ -361,9 +361,9 @@
 }
 #endif
 
-/** Close all open log files. */
+/** Close all open log files, and free other static memory. */
 void
-close_logs(void)
+logs_free_all(void)
 {
   logfile_t *victim, *next;
   next = logfiles;
@@ -375,6 +375,7 @@
     tor_free(victim->filename);
     tor_free(victim);
   }
+  tor_free(appname);
 }
 
 /** Remove and free the log entry <b>victim</b> from the linked-list

Modified: tor/trunk/src/common/log.h
===================================================================
--- tor/trunk/src/common/log.h	2007-07-16 03:40:25 UTC (rev 10836)
+++ tor/trunk/src/common/log.h	2007-07-16 04:33:47 UTC (rev 10837)
@@ -104,7 +104,7 @@
 int add_callback_log(int loglevelMin, int loglevelMax, log_callback cb);
 int get_min_log_level(void);
 void switch_logs_debug(void);
-void close_logs(void);
+void logs_free_all(void);
 void add_temp_log(void);
 void close_temp_logs(void);
 void rollback_log_changes(void);

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-07-16 03:40:25 UTC (rev 10836)
+++ tor/trunk/src/or/main.c	2007-07-16 04:33:47 UTC (rev 10837)
@@ -1741,10 +1741,13 @@
 }
 
 /** Free all memory that we might have allocated somewhere.
- * Helps us find the real leaks with dmalloc and the like.
+ * If <b>postfork</b>, we are a worker process and we want to free
+ * only the parts of memory that we won't touch. If !<b>postfork</b>,
+ * Tor is shutting down and we should free everything.
  *
- * Also valgrind should then report 0 reachable in its
- * leak report */
+ * Helps us find the real leaks with dmalloc and the like. Also valgrind
+ * should then report 0 reachable in its leak report (in an ideal world --
+ * in practice libevent, ssl, libc etc never quite free everything). */
 void
 tor_free_all(int postfork)
 {
@@ -1772,13 +1775,14 @@
   free_cell_pool();
   tor_tls_free_all();
   /* stuff in main.c */
+  smartlist_free(connection_array);
   smartlist_free(closeable_connection_lst);
   smartlist_free(active_linked_connection_lst);
   tor_free(timeout_event);
   /* Stuff in util.c */
   escaped(NULL);
   if (!postfork) {
-    close_logs(); /* free log strings. do this last so logs keep working. */
+    logs_free_all(); /* free log strings. do this last so logs keep working. */
   }
 }