diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-23 06:08:08 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-23 06:08:08 +0000 |
commit | f5319a010d65fc2e1c178c5d040511e6e6328647 (patch) | |
tree | 0de52b9157b63c6707650f44c9c99ff786d928fb | |
parent | 1520a4a063ae90c740dd4ac9df3fa2178ce96b56 (diff) | |
download | tor-f5319a010d65fc2e1c178c5d040511e6e6328647.tar.gz tor-f5319a010d65fc2e1c178c5d040511e6e6328647.zip |
Dr. Seuss on iterating circular lists: "It's fun to have fun, but you
have to know how."
svn:r2948
-rw-r--r-- | src/or/circuitbuild.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index bf2c2b859d..1108b688a8 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -86,9 +86,12 @@ circuit_list_path(circuit_t *circ, int verbose) smartlist_add(elements, tor_strdup(buf)); } - for (hop = circ->cpath; hop && hop != circ->cpath; hop = hop->next) { + hop = circ->cpath; + do { const char *elt; routerinfo_t *r; + if (!hop) + break; if (!verbose && hop->state != CPATH_STATE_OPEN) break; if ((r = router_get_by_digest(hop->identity_digest))) { @@ -109,7 +112,8 @@ circuit_list_path(circuit_t *circ, int verbose) } else { smartlist_add(elements, tor_strdup(elt)); } - } + hop = hop->next; + } while (hop != circ->cpath); s = smartlist_join_strings(elements, verbose?" ":",", 0, NULL); SMARTLIST_FOREACH(elements, char*, cp, tor_free(cp)); @@ -212,10 +216,14 @@ circuit_dump_details(int severity, circuit_t *circ, int poll_index, if(circ->state == CIRCUIT_STATE_BUILDING) log(severity,"Building: desired len %d, planned exit node %s.", circ->build_state->desired_path_len, circ->build_state->chosen_exit_name); - for(hop=circ->cpath;hop->next != circ->cpath; hop=hop->next) + hop = circ->cpath; + do { + if (!hop) break; log(severity,"hop: state %d, addr 0x%.8x, port %d", hop->state, (unsigned int)hop->addr, (int)hop->port); + hop = hop->next; + } while (hop != circ->cpath); } } |