diff options
author | Roger Dingledine <arma@torproject.org> | 2006-06-06 03:33:24 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2006-06-06 03:33:24 +0000 |
commit | 96914760bc32a6ee9ed49218a9fbd020588f783b (patch) | |
tree | 91a9d7865ba792ff4ca82c119da8d03957e7176a /src/or/circuitbuild.c | |
parent | 5e4b4451ec42d4ee92dac8f820153a9a38e4d4d8 (diff) | |
download | tor-96914760bc32a6ee9ed49218a9fbd020588f783b.tar tor-96914760bc32a6ee9ed49218a9fbd020588f783b.tar.gz |
fix the bug where we sometimes would fail to send some create cells
once we'd connected to a(nother) tor server.
svn:r6552
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r-- | src/or/circuitbuild.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 5d46342e0..00571a5a6 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -404,6 +404,7 @@ void circuit_n_conn_done(connection_t *or_conn, int status) { extern smartlist_t *circuits_pending_or_conns; + smartlist_t *changed_circs; log_debug(LD_CIRC,"or_conn to %s, status=%d", or_conn->nickname ? or_conn->nickname : "NULL", status); @@ -411,6 +412,8 @@ circuit_n_conn_done(connection_t *or_conn, int status) if (!circuits_pending_or_conns) return; + changed_circs = smartlist_create(); + SMARTLIST_FOREACH(circuits_pending_or_conns, circuit_t *, circ, { if (circ->marked_for_close) @@ -454,18 +457,18 @@ circuit_n_conn_done(connection_t *or_conn, int status) continue; } tor_free(circ->onionskin); - circuit_set_state(circ, CIRCUIT_STATE_OPEN); - /* XXX: Since circuit_set_state removes circ from the - * circuits_pending_or_conns, we will skip over whatever - * the next entry is when we proceed with the SMARTLIST_FOREACH. - * Thus if there's ever more than one entry, we will miss some. - * - * Is this true? If so, is the fix to decrement circ_sl_idx - * here too? -RD - */ + /* We don't want to change circ's state here, since the act + * of doing that modifies the circuits_pending_or_conns list + * that we're looping through right now. So collect a list of + * circs to change their state when we're done. */ + smartlist_add(changed_circs, circ); } } }); + + SMARTLIST_FOREACH(changed_circs, circuit_t *, circ, + circuit_set_state(circ, CIRCUIT_STATE_OPEN)); + smartlist_free(changed_circs); } /** Find a new circid that isn't currently in use on the circ->n_conn |