Merge remote-tracking branch 'andrea/bug18116'

This commit is contained in:
Nick Mathewson 2016-02-10 15:42:11 -05:00
commit ee75c02691
2 changed files with 31 additions and 0 deletions

3
changes/bug18116 Normal file
View File

@ -0,0 +1,3 @@
o Major bugfixes:
- Correctly handle detaching circuits from cmuxes when doing
circuit_free_all() on shutdown again; fixes bug #18116.

View File

@ -53,6 +53,7 @@ static void cpath_ref_decref(crypt_path_reference_t *cpath_ref);
//static void circuit_set_rend_token(or_circuit_t *circ, int is_rend_circ,
// const uint8_t *token);
static void circuit_clear_rend_token(or_circuit_t *circ);
static void circuit_about_to_free_terminal(circuit_t *circ);
static void circuit_about_to_free(circuit_t *circ);
/********* END VARIABLES ************/
@ -901,6 +902,7 @@ circuit_free_all(void)
}
}
tmp->global_circuitlist_idx = -1;
circuit_about_to_free_terminal(tmp);
circuit_free(tmp);
SMARTLIST_DEL_CURRENT(lst, tmp);
} SMARTLIST_FOREACH_END(tmp);
@ -1744,6 +1746,32 @@ circuit_mark_for_close_, (circuit_t *circ, int reason, int line,
smartlist_add(circuits_pending_close, circ);
}
/** Called immediately before freeing a marked circuit <b>circ</b> from
* circuit_free_all() while shutting down Tor; this is a safe-at-shutdown
* version of circuit_about_to_free(). It's important that it at least
* do circuitmux_detach_circuit() when appropriate.
*/
static void
circuit_about_to_free_terminal(circuit_t *circ)
{
if (circ->n_chan) {
circuit_clear_cell_queue(circ, circ->n_chan);
circuitmux_detach_circuit(circ->n_chan->cmux, circ);
circuit_set_n_circid_chan(circ, 0, NULL);
}
if (! CIRCUIT_IS_ORIGIN(circ)) {
or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
if (or_circ->p_chan) {
circuit_clear_cell_queue(circ, or_circ->p_chan);
circuitmux_detach_circuit(or_circ->p_chan->cmux, circ);
circuit_set_p_circid_chan(or_circ, 0, NULL);
}
}
}
/** Called immediately before freeing a marked circuit <b>circ</b>.
* Disconnects the circuit from other data structures, launches events
* as appropriate, and performs other housekeeping.