diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-07-30 18:55:24 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-07-30 18:55:24 -0400 |
commit | 6f45101327592333dcc54e08800fbc2cb68ccd49 (patch) | |
tree | 6ed550c89289a454c4436fc9facec1d7de206b8d /src/or/relay.c | |
parent | 15424bf800a56007d802db3a9d3fe40fbdf2bee5 (diff) | |
download | tor-6f45101327592333dcc54e08800fbc2cb68ccd49.tar.gz tor-6f45101327592333dcc54e08800fbc2cb68ccd49.zip |
Clear cell queues when marking or truncating a circuit.
At best, this patch helps us avoid sending queued relayed cells that
would get ignored during the time between when a destroy cell is
sent and when the circuit is finally freed. At worst, it lets us
release some memory a little earlier than it would otherwise.
Fix for bug #1184. Bugfix on 0.2.0.1-alpha.
Diffstat (limited to 'src/or/relay.c')
-rw-r--r-- | src/or/relay.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/or/relay.c b/src/or/relay.c index 22ecdaafa0..e740fbf595 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -1186,6 +1186,7 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, } if (circ->n_conn) { uint8_t trunc_reason = *(uint8_t*)(cell->payload + RELAY_HEADER_SIZE); + circuit_clear_cell_queue(circ, circ->n_conn); connection_or_send_destroy(circ->n_circ_id, circ->n_conn, trunc_reason); circuit_set_n_circid_orconn(circ, 0, NULL); @@ -2368,6 +2369,25 @@ decode_address_from_payload(tor_addr_t *addr_out, const char *payload, return payload + 2 + (uint8_t)payload[1]; } +/** Remove all the cells queued on <b>circ</b> for <b>orconn</b>. */ +void +circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn) +{ + cell_queue_t *queue; + if (circ->n_conn == orconn) { + queue = &circ->n_conn_cells; + } else { + or_circuit_t *orcirc = TO_OR_CIRCUIT(circ); + tor_assert(orcirc->p_conn == orconn); + queue = &orcirc->p_conn_cells; + } + + if (queue->n) + make_circuit_inactive_on_conn(circ,orconn); + + cell_queue_clear(queue); +} + /** Fail with an assert if the active circuits ring on <b>orconn</b> is * corrupt. */ void |