[or-cvs] bugfix: when we time out on a stream and detach, send an en...

Roger Dingledine arma at seul.org
Sat Feb 28 23:56:52 UTC 2004


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

Modified Files:
	connection_edge.c or.h 
Log Message:
bugfix: when we time out on a stream and detach, send an end first


Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- connection_edge.c	28 Feb 2004 07:01:22 -0000	1.100
+++ connection_edge.c	28 Feb 2004 23:56:50 -0000	1.101
@@ -104,6 +104,7 @@
     case END_STREAM_REASON_EXITPOLICY:     return "exit policy failed";
     case END_STREAM_REASON_DESTROY:        return "destroyed";
     case END_STREAM_REASON_DONE:           return "closed normally";
+    case END_STREAM_REASON_TIMEOUT:        return "gave up (timeout)";
   }
   assert(0);
   return "";
@@ -531,6 +532,10 @@
     if (now - conn->timestamp_lastread >= 15) {
       log_fn(LOG_WARN,"Stream is %d seconds late. Retrying.",
              (int)(now - conn->timestamp_lastread));
+      /* send an end down the circuit */
+      connection_edge_end(conn, END_STREAM_REASON_TIMEOUT, conn->cpath_layer);
+      /* un-mark it as ending, since we're going to reuse it */
+      conn->has_sent_end = 0;
       /* move it back into 'pending' state. It's possible it will
        * reattach to this same circuit, but that's good enough for now.
        */
@@ -540,11 +545,7 @@
       conn->timestamp_lastread += 15;
       if(connection_ap_handshake_attach_circuit(conn)<0) {
         /* it will never work */
-        /* Don't need to send end -- why? */
-/* XXX you're right, there's a bug. we should send an end cell
- * above, right before circuit_detach_stream. But if attach_circuit()
- * fails, then in fact we should mark without sending an end, because
- * we're not connected to anything. -RD */
+        /* Don't need to send end -- we're not connected */
         connection_mark_for_close(conn, 0);
       }
     }
@@ -567,7 +568,7 @@
       continue;
     if(connection_ap_handshake_attach_circuit(conn) < 0) {
       /* -1 means it will never work */
-      /* Don't send end; there is no 'other end' of the stream */
+      /* Don't send end; there is no 'other side' yet */
       connection_mark_for_close(conn,0);
     }
   }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.236
retrieving revision 1.237
diff -u -d -r1.236 -r1.237
--- or.h	28 Feb 2004 22:23:44 -0000	1.236
+++ or.h	28 Feb 2004 23:56:50 -0000	1.237
@@ -196,7 +196,8 @@
 #define END_STREAM_REASON_EXITPOLICY 4
 #define END_STREAM_REASON_DESTROY 5
 #define END_STREAM_REASON_DONE 6
-#define _MAX_END_STREAM_REASON 6
+#define END_STREAM_REASON_TIMEOUT 7
+#define _MAX_END_STREAM_REASON 7
 
 /* default cipher function */
 #define DEFAULT_CIPHER CRYPTO_CIPHER_AES_CTR



More information about the tor-commits mailing list