aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/log.c5
-rw-r--r--src/common/log.h2
-rw-r--r--src/or/main.c12
3 files changed, 12 insertions, 7 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 83ed7d143..d471e9f1e 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -361,9 +361,9 @@ _log_err(uint32_t domain, const char *format, ...)
}
#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 @@ close_logs(void)
tor_free(victim->filename);
tor_free(victim);
}
+ tor_free(appname);
}
/** Remove and free the log entry <b>victim</b> from the linked-list
diff --git a/src/common/log.h b/src/common/log.h
index 01ab82de7..e68614045 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -104,7 +104,7 @@ int add_syslog_log(int loglevelMin, int loglevelMax);
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);
diff --git a/src/or/main.c b/src/or/main.c
index 7a5ffb84b..9bd872b3a 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1741,10 +1741,13 @@ tor_init(int argc, char *argv[])
}
/** 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 @@ tor_free_all(int postfork)
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. */
}
}