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

[or-cvs] r9510: Fix third case of bug 367: make circuit get sent along with (in tor/trunk: . src/or)



Author: nickm
Date: 2007-02-07 01:54:22 -0500 (Wed, 07 Feb 2007)
New Revision: 9510

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/circuitlist.c
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/control.c
   tor/trunk/src/or/or.h
Log:
 r11672@catbus:  nickm | 2007-02-06 14:16:56 -0500
 Fix third case of bug 367: make circuit get sent along with END_STREAM_REASON_DESTROY stream CLOSED events.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/unstable_trunk [r11672] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-02-07 05:52:55 UTC (rev 9509)
+++ tor/trunk/ChangeLog	2007-02-07 06:54:22 UTC (rev 9510)
@@ -1,3 +1,11 @@
+Changes in version 0.1.2.8-alpha - 2007-??-??
+  o Minor bugfixes (controller):
+    - Give the controller END_STREAM_REASON_DESTROY events _before_ we
+      clear the corresponding on_circuit variable, and remember later that
+      we don't need to send a redundant CLOSED event.  (Resolves part 3 of
+      bug 367.)
+
+
 Changes in version 0.1.2.7-alpha - 2007-02-06
   o Major bugfixes (rate limiting):
     - Servers decline directory requests much more aggressively when

Modified: tor/trunk/src/or/circuitlist.c
===================================================================
--- tor/trunk/src/or/circuitlist.c	2007-02-07 05:52:55 UTC (rev 9509)
+++ tor/trunk/src/or/circuitlist.c	2007-02-07 06:54:22 UTC (rev 9510)
@@ -953,6 +953,9 @@
          * to send an end cell. */
         conn->_base.edge_has_sent_end = 1;
         conn->end_reason = END_STREAM_REASON_DESTROY;
+        conn->end_reason |= END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED;
+        control_event_stream_status(conn, STREAM_EVENT_CLOSED,
+                                    END_STREAM_REASON_DESTROY);
         connection_mark_for_close(TO_CONN(conn));
       }
       conn->on_circuit = NULL;

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2007-02-07 05:52:55 UTC (rev 9509)
+++ tor/trunk/src/or/connection_edge.c	2007-02-07 06:54:22 UTC (rev 9510)
@@ -158,6 +158,9 @@
       /* closing the circuit, nothing to send an END to */
       conn->_base.edge_has_sent_end = 1;
       conn->end_reason = END_STREAM_REASON_DESTROY;
+      conn->end_reason |= END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED;
+      control_event_stream_status(conn, STREAM_EVENT_CLOSED,
+                                  END_STREAM_REASON_DESTROY);
       connection_mark_for_close(TO_CONN(conn));
       conn->_base.hold_open_until_flushed = 1;
     }

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2007-02-07 05:52:55 UTC (rev 9509)
+++ tor/trunk/src/or/control.c	2007-02-07 06:54:22 UTC (rev 9510)
@@ -3140,7 +3140,7 @@
 static const char *
 stream_end_reason_to_string(int reason)
 {
-  reason &= ~END_CIRC_REASON_FLAG_REMOTE;
+  reason &= END_STREAM_REASON_MASK;
   switch (reason) {
     case END_STREAM_REASON_MISC: return "MISC";
     case END_STREAM_REASON_RESOLVEFAILED: return "RESOLVEFAILED";
@@ -3179,6 +3179,10 @@
   if (!EVENT_IS_INTERESTING(EVENT_STREAM_STATUS))
     return 0;
 
+  if (tp == STREAM_EVENT_CLOSED &&
+      (reason_code & END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED))
+    return 0;
+
   write_stream_target_to_buf(conn, buf, sizeof(buf));
   if (EVENT_IS_INTERESTING0(EVENT_STREAM_STATUS)) {
     len = strlen(buf);

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-02-07 05:52:55 UTC (rev 9509)
+++ tor/trunk/src/or/or.h	2007-02-07 06:54:22 UTC (rev 9510)
@@ -531,9 +531,15 @@
 /** DOCDOC */
 #define END_STREAM_REASON_INVALID_NATD_DEST 261
 
+/** Bitwise-and this value with endreason to mask out all flags. */
+#define END_STREAM_REASON_MASK 511
+
 /** Bitwise-or this with the argument to control_event_stream_status
  * to indicate that the reason came from an END cell. */
-#define END_STREAM_REASON_FLAG_REMOTE     512
+#define END_STREAM_REASON_FLAG_REMOTE 512
+/** Bitwise-or this with the argument to control_event_stream_status
+ * to indicate that we already sent a CLOSED stream event. */
+#define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED 1024
 
 /* DOCDOC */
 #define RESOLVED_TYPE_HOSTNAME 0