[or-cvs] Better fix for last bug: avoids trying to double-mark circu...
Nick Mathewson
nickm at seul.org
Mon Dec 5 19:45:56 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv13522/src/or
Modified Files:
circuitlist.c circuituse.c or.h
Log Message:
Better fix for last bug: avoids trying to double-mark circuits.
Index: circuitlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- circuitlist.c 5 Dec 2005 19:26:09 -0000 1.82
+++ circuitlist.c 5 Dec 2005 19:45:54 -0000 1.83
@@ -458,20 +458,24 @@
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:
Index: circuituse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- circuituse.c 5 Dec 2005 00:15:42 -0000 1.100
+++ circuituse.c 5 Dec 2005 19:45:54 -0000 1.101
@@ -515,21 +515,10 @@
*/
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:
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.748
retrieving revision 1.749
diff -u -d -r1.748 -r1.749
--- or.h 5 Dec 2005 19:15:27 -0000 1.748
+++ or.h 5 Dec 2005 19:45:54 -0000 1.749
@@ -1446,7 +1446,7 @@
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,
More information about the tor-commits
mailing list