[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Function to cancel a guard state.



commit 8e43398986313f31bfda53aa798263972bf24c11
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Nov 22 10:03:18 2016 -0500

    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."
---
 src/or/entrynodes.c | 23 +++++++++++++++++++++++
 src/or/entrynodes.h |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index cda5540..24a3448 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 7119d54..60191ab 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);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits