diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-11-22 10:03:18 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-11-30 14:42:53 -0500 |
commit | 8e43398986313f31bfda53aa798263972bf24c11 (patch) | |
tree | 97314ffdd9df87420b2d41fc6b1ec747df93e442 /src | |
parent | 4689096ed165e893a541b11520b347fc03e39db0 (diff) | |
download | tor-8e43398986313f31bfda53aa798263972bf24c11.tar.gz tor-8e43398986313f31bfda53aa798263972bf24c11.zip |
Function to cancel a guard state.
We'll want to use this if we allocate a guard state then decide,
"whoops, we don't want to use this."
Diffstat (limited to 'src')
-rw-r--r-- | src/or/entrynodes.c | 23 | ||||
-rw-r--r-- | src/or/entrynodes.h | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c index cda554049d..24a3448969 100644 --- a/src/or/entrynodes.c +++ b/src/or/entrynodes.c @@ -1347,6 +1347,29 @@ entry_guard_succeeded(guard_selection_t *gs, } } +/** Cancel the selection of *<b>guard_state_p</b> without declaring + * success or failure. It is safe to call this function if success or + * failure _has_ already been declared. */ +void +entry_guard_cancel(guard_selection_t *gs, + circuit_guard_state_t **guard_state_p) +{ + (void) gs; + if (get_options()->UseDeprecatedGuardAlgorithm) + return; + if (BUG(*guard_state_p == NULL)) + return; + entry_guard_t *guard = entry_guard_handle_get((*guard_state_p)->guard); + if (! guard) + return; + + /* XXXX prop271 -- last_tried_to_connect_at will be erroneous here, but this + * function will only get called in "bug" cases anyway. */ + guard->is_pending = 0; + circuit_guard_state_free(*guard_state_p); + *guard_state_p = NULL; +} + /** * Called by the circuit building module when a circuit has succeeded: * informs the guards code that the guard in *<b>guard_state_p</b> is diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h index 7119d547b1..60191ab8b9 100644 --- a/src/or/entrynodes.h +++ b/src/or/entrynodes.h @@ -322,6 +322,8 @@ int entry_guard_succeeded(guard_selection_t *gs, circuit_guard_state_t **guard_state_p); void entry_guard_failed(guard_selection_t *gs, circuit_guard_state_t **guard_state_p); +void entry_guard_cancel(guard_selection_t *gs, + circuit_guard_state_t **guard_state_p); void entry_guard_chan_failed(guard_selection_t *gs, channel_t *chan); void entry_guards_update_all(guard_selection_t *gs); |