aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-21 17:18:35 -0500
committerNick Mathewson <nickm@torproject.org>2016-11-30 14:42:53 -0500
commitaf1918d28999c2c38ace984296927d9244c7c7b1 (patch)
tree187b1eac40808fdd4f9f4ff935e53a802471a9dd
parent1fd0a547bb6af73cbc32be06ffbf6233eb9050a6 (diff)
downloadtor-af1918d28999c2c38ace984296927d9244c7c7b1.tar.gz
tor-af1918d28999c2c38ace984296927d9244c7c7b1.zip
New entry_guard_chan_failed function
To be called when an entire channel has failed: tell any/all circuits pending for the guard of that channel that they have failed.
-rw-r--r--src/or/entrynodes.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 4a998975d8..2b6fd51116 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -124,6 +124,7 @@
#include "bridges.h"
#include "circpathbias.h"
#include "circuitbuild.h"
+#include "circuitlist.h"
#include "circuitstats.h"
#include "config.h"
#include "confparse.h"
@@ -1371,7 +1372,30 @@ entry_guard_failed(guard_selection_t *gs,
(*guard_state_p)->state = GUARD_CIRC_STATE_DEAD;
(*guard_state_p)->state_set_at = approx_time();
- return 0;
+/**
+ * Run the entry_guard_failed() function on every circuit that is
+ * pending on <b>chan</b>.
+ */
+void
+entry_guard_chan_failed(guard_selection_t *gs,
+ channel_t *chan)
+{
+ tor_assert(gs);
+ if (!chan)
+ return;
+ if (get_options()->UseDeprecatedGuardAlgorithm)
+ return;
+
+ smartlist_t *pending = smartlist_new();
+ circuit_get_all_pending_on_channel(pending, chan);
+ SMARTLIST_FOREACH_BEGIN(pending, circuit_t *, circ) {
+ if (!CIRCUIT_IS_ORIGIN(circ))
+ continue;
+
+ origin_circuit_t *origin_circ = TO_ORIGIN_CIRCUIT(circ);
+ entry_guard_failed(gs, &origin_circ->guard_state);
+ } SMARTLIST_FOREACH_END(circ);
+ smartlist_free(pending);
}
/**