Commit 6d2cb32d authored by Roger Dingledine's avatar Roger Dingledine
Browse files

free some more memory on exit


svn:r10837
parent 4b719cba
......@@ -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
......
......@@ -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);
......
......@@ -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. */
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment