diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-12-05 19:45:54 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-12-05 19:45:54 +0000 |
commit | d2123388adc8af36a19446a8eee7ee64eeef90ec (patch) | |
tree | 04e61461392a05d4f56e38238c2a6e0986d1029c /src | |
parent | fedc9c8a605b07d2c1e1c2e8b08f80c1051dbf47 (diff) | |
download | tor-d2123388adc8af36a19446a8eee7ee64eeef90ec.tar tor-d2123388adc8af36a19446a8eee7ee64eeef90ec.tar.gz |
Better fix for last bug: avoids trying to double-mark circuits.
svn:r5511
Diffstat (limited to 'src')
-rw-r--r-- | src/or/circuitlist.c | 24 | ||||
-rw-r--r-- | src/or/circuituse.c | 13 | ||||
-rw-r--r-- | src/or/or.h | 2 |
3 files changed, 16 insertions, 23 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index c9db1e9da..6ab5a10a5 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -458,20 +458,24 @@ circuit_get_by_edge_conn(connection_t *conn) return circ; } -/** Return a new list of all circuits that have <b>conn</b> as n_conn or - * p_conn, including those marked for close. +/** For each circuits that have <b>conn</b> as n_conn or p_conn, unlink the + * circuit from the orconn,circid map, and mark it for close if it hasn't + * been marked already. */ -smartlist_t * -circuit_get_all_on_orconn(connection_t *conn) +void +circuit_unlink_all_from_or_conn(connection_t *conn) { - smartlist_t *res = smartlist_create(); circuit_t *circ; - - for (circ=global_circuitlist;circ;circ = circ->next) { - if (circ->p_conn == conn || circ->n_conn == conn) - smartlist_add(res, circ); + for (circ = global_circuitlist; circ; circ = circ->next) { + if (circ->n_conn == conn || circ->p_conn == conn) { + if (circ->n_conn == conn) + circuit_set_circid_orconn(circ, 0, NULL, N_CONN_CHANGED); + if (circ->p_conn == conn) + circuit_set_circid_orconn(circ, 0, NULL, P_CONN_CHANGED); + if (!circ->marked_for_close) + circuit_mark_for_close(circ); + } } - return res; } /** Return a circ such that: diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 4afa2f5ea..550b6d6de 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -515,21 +515,10 @@ circuit_about_to_close_connection(connection_t *conn) */ switch (conn->type) { case CONN_TYPE_OR: { - smartlist_t *circs; /* Inform any pending (not attached) circs that they should give up. */ circuit_n_conn_done(conn, 0); - circs = circuit_get_all_on_orconn(conn); /* Now close all the attached circuits on it. */ - SMARTLIST_FOREACH(circs, circuit_t *, circ, { - if (circ->n_conn == conn) - /* it's closing in front of us */ - circuit_set_circid_orconn(circ, 0, NULL, N_CONN_CHANGED); - if (circ->p_conn == conn) - /* it's closing behind us */ - circuit_set_circid_orconn(circ, 0, NULL, P_CONN_CHANGED); - circuit_mark_for_close(circ); - }); - smartlist_free(circs); + circuit_unlink_all_from_or_conn(conn); return; } case CONN_TYPE_AP: diff --git a/src/or/or.h b/src/or/or.h index e80ed71e1..61b924001 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1446,7 +1446,7 @@ circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn); circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id, connection_t *conn); int circuit_id_used_on_conn(uint16_t circ_id, connection_t *conn); circuit_t *circuit_get_by_edge_conn(connection_t *conn); -smartlist_t *circuit_get_all_on_orconn(connection_t *conn); +void circuit_unlink_all_from_or_conn(connection_t *conn); circuit_t *circuit_get_by_global_id(uint32_t id); circuit_t *circuit_get_by_rend_query_and_purpose(const char *rend_query, uint8_t purpose); circuit_t *circuit_get_next_by_pk_and_purpose(circuit_t *start, |