summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-29 11:47:12 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-16 11:06:19 -0500
commit84bfa895d725338d92f677a31a4dcf6381845e0c (patch)
tree048ac001141964a38514f0f061c32601cd46c251 /src/or/circuitbuild.c
parent46619ec9143450b181a8510011d3e3fd92542aa4 (diff)
downloadtor-84bfa895d725338d92f677a31a4dcf6381845e0c.tar.gz
tor-84bfa895d725338d92f677a31a4dcf6381845e0c.zip
Change return value of entry_guard_succeeded to an enum.
George pointed out that (-1,0,1) for (never usable, maybe usable later, usable right now) was a pretty rotten convention that made the code harder to read.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 5d0a04fe71..c7e116e853 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -964,28 +964,29 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
memset(&ec, 0, sizeof(ec));
if (!hop) {
/* done building the circuit. whew. */
- int r;
+ guard_usable_t r;
if (get_options()->UseDeprecatedGuardAlgorithm) {
// The circuit is usable; we already marked the guard as okay.
- r = 1;
+ r = GUARD_USABLE_NOW;
} else if (! circ->guard_state) {
if (circuit_get_cpath_len(circ) != 1) {
log_warn(LD_BUG, "%d-hop circuit %p with purpose %d has no "
"guard state",
circuit_get_cpath_len(circ), circ, circ->base_.purpose);
}
- r = 1;
+ r = GUARD_USABLE_NOW;
} else {
r = entry_guard_succeeded(&circ->guard_state);
}
- const int is_usable_for_streams = (r == 1);
- if (r == 1) {
+ const int is_usable_for_streams = (r == GUARD_USABLE_NOW);
+ if (r == GUARD_USABLE_NOW) {
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_OPEN);
- } else if (r == 0) {
+ } else if (r == GUARD_MAYBE_USABLE_LATER) {
// XXXX prop271 we might want to probe for whether this
// XXXX one is ready even before the next second rolls over.
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_GUARD_WAIT);
} else {
+ tor_assert_nonfatal(r == GUARD_USABLE_NEVER);
return - END_CIRC_REASON_INTERNAL;
}