]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix a bug in our bug 9776 fix.
authorNick Mathewson <nickm@torproject.org>
Thu, 3 Oct 2013 01:42:24 +0000 (21:42 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 3 Oct 2013 02:20:18 +0000 (22:20 -0400)
By calling circuit_n_chan_done() unconditionally on close, we were
closing pending connections that might not have been pending quite for
the connection we were closing.  Fix for bug 9880.

Thanks to skruffy for finding this and explaining it patiently until
we understood.

changes/bug9880 [new file with mode: 0644]
src/or/channel.c
src/or/channel.h

diff --git a/changes/bug9880 b/changes/bug9880
new file mode 100644 (file)
index 0000000..a7dda8f
--- /dev/null
@@ -0,0 +1,8 @@
+  o Minor bugfixes:
+
+    - When closing a channel that has already been open, do not close
+      pending circuits that were waiting to connect to the same relay.
+      Fixes bug 9880; bugfix on 0.2.5.1-alpha. Thanks to skruffy for
+      finding this bug.  (Bug was merged to 0.2.4 branch but not released
+      in any 0.2.4 version)
+
index 1fb39b88cac42bc6ac36cc234dd13810b12ff4e9..1270eace7d7b0dc1652ce39ed8d8e4542760080d 100644 (file)
@@ -743,6 +743,9 @@ channel_init(channel_t *chan)
 
   /* Timestamp it */
   channel_timestamp_created(chan);
+
+  /* It hasn't been open yet. */
+  chan->has_been_open = 0;
 }
 
 /**
@@ -1294,7 +1297,8 @@ channel_closed(channel_t *chan)
 
   /* Inform any pending (not attached) circs that they should
    * give up. */
-  circuit_n_chan_done(chan, 0);
+  if (! chan->has_been_open)
+    circuit_n_chan_done(chan, 0);
 
   /* Now close all the attached circuits on it. */
   circuit_unlink_all_from_channel(chan, END_CIRC_REASON_CHANNEL_CLOSED);
@@ -1935,6 +1939,7 @@ channel_change_state(channel_t *chan, channel_state_t to_state)
   /* Tell circuits if we opened and stuff */
   if (to_state == CHANNEL_STATE_OPEN) {
     channel_do_open_actions(chan);
+    chan->has_been_open = 1;
 
     /* Check for queued cells to process */
     if (! TOR_SIMPLEQ_EMPTY(&chan->incoming_queue))
index 0933ec8d3907f703d8579caf971c14d0628d0d36..2dca81705f7c9466693171d3a52b8f00c745d630 100644 (file)
@@ -46,6 +46,9 @@ struct channel_s {
   /* Should we expect to see this channel in the channel lists? */
   unsigned char registered:1;
 
+  /** has this channel ever been open? */
+  unsigned int has_been_open:1;
+
   /** Why did we close?
    */
   enum {