[or-cvs] but don"t spring the trip on worker children, because it tu...

Roger Dingledine arma at seul.org
Mon Jan 31 01:02:22 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	connection.c 
Log Message:
but don't spring the trip on worker children, because it turns
out they don't actually remove anything before freeing the conns.


Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.318
retrieving revision 1.319
diff -u -d -r1.318 -r1.319
--- connection.c	31 Jan 2005 00:33:32 -0000	1.318
+++ connection.c	31 Jan 2005 01:02:20 -0000	1.319
@@ -140,11 +140,9 @@
  * close its socket if necessary, and mark the directory as dirty if <b>conn</b>
  * is an OR or OP connection.
  */
-void connection_free(connection_t *conn) {
-  tor_assert(conn);
+static void
+_connection_free(connection_t *conn) {
   tor_assert(conn->magic == CONNECTION_MAGIC);
-  tor_assert(!connection_in_array(conn));
-  tor_assert(!connection_is_on_closeable_list(conn));
 
   if (!connection_is_listener(conn)) {
     buf_free(conn->inbuf);
@@ -181,9 +179,21 @@
   tor_free(conn);
 }
 
-/** Call connection_free() on every connection in our array.
+/** Make sure <b>conn</b> isn't in any of the global conn lists; then free it.
+ */
+void connection_free(connection_t *conn) {
+  tor_assert(conn);
+  tor_assert(!connection_is_on_closeable_list(conn));
+  tor_assert(!connection_in_array(conn));
+  _connection_free(conn);
+}
+
+/** Call _connection_free() on every connection in our array.
  * This is used by cpuworkers and dnsworkers when they fork,
  * so they don't keep resources held open (especially sockets).
+ *
+ * Don't do the checks in connection_free(), because they will
+ * fail.
  */
 void connection_free_all(void) {
   int i, n;
@@ -191,7 +201,7 @@
 
   get_connection_array(&carray,&n);
   for (i=0;i<n;i++)
-    connection_free(carray[i]);
+    _connection_free(carray[i]);
 }
 
 /** Do any cleanup needed:



More information about the tor-commits mailing list