summaryrefslogtreecommitdiff
path: root/src/or/entrynodes.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-25 12:53:00 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-16 11:06:16 -0500
commit2ea5aa71823f385e36f20e643a20996dcb164464 (patch)
tree3a1d70c711bdd1fdf0917c2b43bf8c9fb8f3b2a4 /src/or/entrynodes.c
parente56bc1e5de05d9bc6876d91d364d33f0771eb322 (diff)
downloadtor-2ea5aa71823f385e36f20e643a20996dcb164464.tar.gz
tor-2ea5aa71823f385e36f20e643a20996dcb164464.zip
Expire circuits that have been WAITING_FOR_BETTER_GUARD too long
(This is required by 3.9 in prop271, but is better done as a separate function IMO)
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r--src/or/entrynodes.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 951ce15f85..1c9349ee03 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1605,9 +1605,6 @@ entry_guards_upgrade_waiting_circuits(guard_selection_t *gs,
"circuit had higher priority, so not upgrading.",
n_complete, n_waiting);
- /* XXXX prop271 implement: "(Time them out after a
- {NONPRIMARY_GUARD_IDLE_TIMEOUT} seconds.)"
- */
return 0;
}
}
@@ -1672,6 +1669,21 @@ entry_guards_upgrade_waiting_circuits(guard_selection_t *gs,
}
/**
+ * Return true iff the circuit whose state is <b>guard_state</b> should
+ * expire.
+ */
+int
+entry_guard_state_should_expire(circuit_guard_state_t *guard_state)
+{
+ if (guard_state == NULL)
+ return 0;
+ const time_t expire_if_waiting_since =
+ approx_time() - NONPRIMARY_GUARD_IDLE_TIMEOUT;
+ return (guard_state->state == GUARD_CIRC_STATE_WAITING_FOR_BETTER_GUARD
+ && guard_state->state_set_at < expire_if_waiting_since);
+}
+
+/**
* Update all derived pieces of the guard selection state in <b>gs</b>.
* Return true iff we should stop using all previously generated circuits.
*/