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

[or-cvs] Still more code to make sure we send the right number and k...



Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv7605/src/or

Modified Files:
	circuitlist.c connection_edge.c main.c relay.c 
Log Message:
Still more code to make sure we send the right number and kind of RELAY END cells

Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- circuitlist.c	11 Feb 2005 01:26:46 -0000	1.26
+++ circuitlist.c	2 Mar 2005 03:13:05 -0000	1.27
@@ -396,8 +396,12 @@
   while (circ->resolving_streams) {
     conn = circ->resolving_streams;
     circ->resolving_streams = conn->next_stream;
-    if (!conn->marked_for_close)
+    if (!conn->marked_for_close) {
+      /* The other side will see a DESTROY, and infer that the connections
+       * are closing because the circuit is getting torn down.  No need
+       * to send an end cell*/
       connection_mark_for_close(conn);
+    }
   }
   if (circ->p_conn)
     connection_send_destroy(circ->p_circ_id, circ->p_conn);

Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -d -r1.287 -r1.288
--- connection_edge.c	1 Mar 2005 22:42:31 -0000	1.287
+++ connection_edge.c	2 Mar 2005 03:13:05 -0000	1.288
@@ -78,8 +78,7 @@
     case AP_CONN_STATE_OPEN:
     case EXIT_CONN_STATE_OPEN:
       if (connection_edge_package_raw_inbuf(conn, package_partial) < 0) {
-        /* XXXX We can't tell *why* package failed. -NM */
-        connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+        /* (We already sent an end cell if possible) */
         connection_mark_for_close(conn);
         return -1;
       }
@@ -275,6 +274,7 @@
     if (!circ) { /* it's vanished? */
       log_fn(LOG_INFO,"Conn is waiting (address %s), but lost its circ.",
              conn->socks_request->address);
+      conn->has_sent_end = 1; /* No circuit to receive end cell. */
       connection_mark_for_close(conn);
       continue;
     }

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.455
retrieving revision 1.456
diff -u -d -r1.455 -r1.456
--- main.c	28 Feb 2005 22:38:00 -0000	1.455
+++ main.c	2 Mar 2005 03:13:05 -0000	1.456
@@ -358,6 +358,8 @@
       tor_assert(0);
 #endif
 #endif
+      if (CONN_IS_EDGE(conn))
+        connection_edge_end_errno(conn, conn->cpath_layer);
       connection_mark_for_close(conn);
     }
   }

Index: relay.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/relay.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- relay.c	1 Mar 2005 22:42:31 -0000	1.43
+++ relay.c	2 Mar 2005 03:13:05 -0000	1.44
@@ -683,8 +683,7 @@
     conn->socks_request->has_finished = 1;
     /* handle anything that might have queued */
     if (connection_edge_package_raw_inbuf(conn, 1) < 0) {
-      /* XXXX we can't tell why package failed. -NM */
-      connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
+      /* (We already sent an end cell if possible) */
       connection_mark_for_close(conn);
       return 0;
     }
@@ -903,7 +902,12 @@
       conn->package_window += STREAMWINDOW_INCREMENT;
       log_fn(LOG_DEBUG,"stream-level sendme, packagewindow now %d.", conn->package_window);
       connection_start_reading(conn);
-      connection_edge_package_raw_inbuf(conn, 1); /* handle whatever might still be on the inbuf */
+      /* handle whatever might still be on the inbuf */
+      if (connection_edge_package_raw_inbuf(conn, 1) < 0) {
+        /* (We already sent an end cell if possible) */
+        connection_mark_for_close(conn);
+        return 0;
+      }
       return 0;
     case RELAY_COMMAND_RESOLVE:
       if (layer_hint) {
@@ -952,7 +956,8 @@
  * and the appropriate package windows aren't empty, grab a cell
  * and send it down the circuit.
  *
- * Return -1 if conn should be marked for close, else return 0.
+ * Return -1 (and send a RELAY_END cell if necessary) if conn should
+ * be marked for close, else return 0.
  */
 int connection_edge_package_raw_inbuf(connection_t *conn, int package_partial) {
   size_t amount_to_process, length;
@@ -966,7 +971,7 @@
 
   circ = circuit_get_by_conn(conn);
   if (!circ) {
-    log_fn(LOG_INFO,"conn has no circuits! Closing.");
+    log_fn(LOG_INFO,"conn has no circuit! Closing.");
     return -1;
   }
 
@@ -1006,7 +1011,8 @@
 
   if (connection_edge_send_command(conn, circ, RELAY_COMMAND_DATA,
                                    payload, length, conn->cpath_layer) < 0)
-    return 0; /* circuit is closed, don't continue */
+    /* circuit got marked for close, don't continue, don't need to mark conn */
+    return 0;
 
   if (!conn->cpath_layer) { /* non-rendezvous exit */
     tor_assert(circ->package_window > 0);
@@ -1089,7 +1095,11 @@
         (layer_hint && conn->package_window > 0 && conn->cpath_layer == layer_hint)) {
       connection_start_reading(conn);
       /* handle whatever might still be on the inbuf */
-      connection_edge_package_raw_inbuf(conn, 1);
+      if (connection_edge_package_raw_inbuf(conn, 1)<0) {
+        /* (We already sent an end cell if possible) */
+        connection_mark_for_close(conn);
+        continue;
+      }
 
       /* If the circuit won't accept any more data, return without looking
        * at any more of the streams. Any connections that should be stopped