diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-11 09:45:17 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-11 09:45:17 -0500 |
commit | 98682f689be39c833c8718d5983c3e8882b54228 (patch) | |
tree | 018dd3402d6113c413451e5279e2a7f8ed3dcc3c /src/or/hs_circuit.c | |
parent | 58e8094816cb7d2dbc6ecc71892b667e968d9e2d (diff) | |
parent | d68abbe358af41b18c9c54444e49689e2626328d (diff) | |
download | tor-98682f689be39c833c8718d5983c3e8882b54228.tar.gz tor-98682f689be39c833c8718d5983c3e8882b54228.zip |
Merge branch 'maint-0.3.2'
Diffstat (limited to 'src/or/hs_circuit.c')
-rw-r--r-- | src/or/hs_circuit.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c index a232a40c80..95073522ed 100644 --- a/src/or/hs_circuit.c +++ b/src/or/hs_circuit.c @@ -1212,3 +1212,31 @@ hs_circ_send_establish_rendezvous(origin_circuit_t *circ) return -1; } +/* We are about to close or free this <b>circ</b>. Clean it up from any + * related HS data structures. This function can be called multiple times + * safely for the same circuit. */ +void +hs_circ_cleanup(circuit_t *circ) +{ + tor_assert(circ); + + /* If it's a service-side intro circ, notify the HS subsystem for the intro + * point circuit closing so it can be dealt with cleanly. */ + if (circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO || + circ->purpose == CIRCUIT_PURPOSE_S_INTRO) { + hs_service_intro_circ_has_closed(TO_ORIGIN_CIRCUIT(circ)); + } + + /* Clear HS circuitmap token for this circ (if any). Very important to be + * done after the HS subsystem has been notified of the close else the + * circuit will not be found. + * + * We do this at the close if possible because from that point on, the + * circuit is good as dead. We can't rely on removing it in the circuit + * free() function because we open a race window between the close and free + * where we can't register a new circuit for the same intro point. */ + if (circ->hs_token) { + hs_circuitmap_remove_circuit(circ); + } +} + |