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

[or-cvs] be sure to detach streams from the circuit linked list befo...



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

Modified Files:
	connection.c connection_edge.c dns.c 
Log Message:
be sure to detach streams from the circuit linked list before freeing them

also, don't bother marking a conn for close if you're about to free it


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -d -r1.229 -r1.230
--- connection.c	21 May 2004 12:25:15 -0000	1.229
+++ connection.c	2 Jun 2004 18:32:24 -0000	1.230
@@ -175,6 +175,8 @@
 void connection_about_to_close_connection(connection_t *conn)
 {
 
+  assert(conn->marked_for_close);
+
   if(conn->type == CONN_TYPE_AP || conn->type == CONN_TYPE_EXIT) {
     if(!conn->has_sent_end)
       log_fn(LOG_WARN,"Edge connection hasn't sent end yet? Bug.");

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- connection_edge.c	20 May 2004 22:39:01 -0000	1.192
+++ connection_edge.c	2 Jun 2004 18:32:24 -0000	1.193
@@ -648,7 +648,6 @@
     if(rend_service_set_connection_addr_port(n_stream, circ) < 0) {
       log_fn(LOG_INFO,"Didn't find rendezvous service (port %d)",n_stream->port);
       connection_edge_end(n_stream, END_STREAM_REASON_EXITPOLICY, n_stream->cpath_layer);
-      connection_mark_for_close(n_stream);
       connection_free(n_stream);
       circuit_mark_for_close(circ); /* knock the whole thing down, somebody screwed up */
       return 0;
@@ -683,7 +682,6 @@
     case -1: /* resolve failed */
       log_fn(LOG_INFO,"Resolve failed (%s).", n_stream->address);
       connection_edge_end(n_stream, END_STREAM_REASON_RESOLVEFAILED, n_stream->cpath_layer);
-      connection_mark_for_close(n_stream);
       connection_free(n_stream);
       break;
     case 0: /* resolve added to pending list */
@@ -710,7 +708,6 @@
       router_compare_to_my_exit_policy(conn) == ADDR_POLICY_REJECTED) {
     log_fn(LOG_INFO,"%s:%d failed exit policy. Closing.", conn->address, conn->port);
     connection_edge_end(conn, END_STREAM_REASON_EXITPOLICY, conn->cpath_layer);
-    connection_mark_for_close(conn);
     circuit_detach_stream(circuit_get_by_conn(conn), conn);
     connection_free(conn);
     return;
@@ -720,7 +717,6 @@
   switch(connection_connect(conn, conn->address, conn->addr, conn->port)) {
     case -1:
       connection_edge_end(conn, END_STREAM_REASON_CONNECTFAILED, conn->cpath_layer);
-      connection_mark_for_close(conn);
       circuit_detach_stream(circuit_get_by_conn(conn), conn);
       connection_free(conn);
       return;

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- dns.c	2 Jun 2004 18:12:49 -0000	1.97
+++ dns.c	2 Jun 2004 18:32:24 -0000	1.98
@@ -125,7 +125,7 @@
         pendconn = pend->conn;
         connection_edge_end(pendconn, END_STREAM_REASON_MISC,
                             pendconn->cpath_layer);
-        connection_mark_for_close(pendconn);
+        circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn);
         connection_free(pendconn);
         tor_free(pend);
       }
@@ -360,15 +360,13 @@
          address);
   while(resolve->pending_connections) {
     pend = resolve->pending_connections;
-    /* So that mark_for_close doesn't double-remove the connection. */
     pend->conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
-    pendconn = pend->conn; /* don't pass complex things to the
-                              connection_mark_for_close macro */
+    pendconn = pend->conn;
     tor_assert(pendconn->s == -1);
     if(!pendconn->marked_for_close) {
       connection_edge_end(pendconn, END_STREAM_REASON_MISC, pendconn->cpath_layer);
-      connection_mark_for_close(pendconn);
     }
+    circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn);
     connection_free(pendconn);
     resolve->pending_connections = pend->next;
     tor_free(pend);
@@ -460,7 +458,6 @@
       pendconn->state = EXIT_CONN_STATE_RESOLVEFAILED;
       circuit_detach_stream(circuit_get_by_conn(pendconn), pendconn);
       connection_edge_end(pendconn, END_STREAM_REASON_MISC, pendconn->cpath_layer);
-      connection_mark_for_close(pendconn);
       connection_free(pendconn);
     } else {
       /* prevent double-remove. */