[or-cvs] Fix not-freed-on-exit event

Nick Mathewson nickm at seul.org
Tue May 24 17:13:18 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv3306/src/or

Modified Files:
	main.c 
Log Message:
Fix not-freed-on-exit event

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.501
retrieving revision 1.502
diff -u -d -r1.501 -r1.502
--- main.c	23 May 2005 22:20:54 -0000	1.501
+++ main.c	24 May 2005 17:13:15 -0000	1.502
@@ -768,10 +768,11 @@
   close_closeable_connections();
 }
 
+static struct event *timeout_event = NULL;
+
 /** Libevent callback: invoked once every second. */
 static void second_elapsed_callback(int fd, short event, void *args)
 {
-  static struct event *timeout_event = NULL;
   static struct timeval one_second;
   static long current_second = 0;
   struct timeval now;
@@ -780,7 +781,6 @@
   int seconds_elapsed;
   or_options_t *options = get_options();
   if (!timeout_event) {
-    /* XXX NM: We don't free timeout_event on exit. */
     timeout_event = tor_malloc_zero(sizeof(struct event));
     evtimer_set(timeout_event, second_elapsed_callback, NULL);
     one_second.tv_sec = 1;
@@ -1251,6 +1251,7 @@
   tor_tls_free_all();
   /* stuff in main.c */
   smartlist_free(closeable_connection_lst);
+  tor_free(timeout_event);
 
   if (!postfork) {
     close_logs(); /* free log strings. do this last so logs keep working. */



More information about the tor-commits mailing list