aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-01-19 17:59:37 +0000
committerRoger Dingledine <arma@torproject.org>2005-01-19 17:59:37 +0000
commit75d83827e0374252bd5c91cbfa0b67e36ad70741 (patch)
tree73b3b33c771ef0fb47d1ebecab884df3eeb5938e /src/or/circuitbuild.c
parentf2a7ff6801d2afa51e4c47cfeffdeea4ab1d2cfe (diff)
downloadtor-75d83827e0374252bd5c91cbfa0b67e36ad70741.tar.gz
tor-75d83827e0374252bd5c91cbfa0b67e36ad70741.zip
fix another bug where general exit circs were looking at rendezvous
streams. consolidate the looking into one function so it doesn't happen again. svn:r3372
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 33998ba885..29937028dc 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -861,6 +861,17 @@ router_handles_some_port(routerinfo_t *router, smartlist_t *needed_ports) {
*/
#define MIN_CIRCUITS_HANDLING_STREAM 2
+static int
+ap_stream_wants_exit_attention(connection_t *conn) {
+ if (conn->type == CONN_TYPE_AP &&
+ conn->state == AP_CONN_STATE_CIRCUIT_WAIT &&
+ !conn->marked_for_close &&
+ !connection_edge_is_rendezvous_stream(conn) &&
+ !circuit_stream_is_being_handled(conn, 0, MIN_CIRCUITS_HANDLING_STREAM))
+ return 1;
+ return 0;
+}
+
/** Return a pointer to a suitable router to be the exit node for the
* general-purpose circuit we're about to build.
*
@@ -893,10 +904,7 @@ choose_good_exit_server_general(routerlist_t *dir, int need_uptime,
* We use this for log messages now, but in the future we may depend on it.
*/
for (i = 0; i < n_connections; ++i) {
- if (carray[i]->type == CONN_TYPE_AP &&
- carray[i]->state == AP_CONN_STATE_CIRCUIT_WAIT &&
- !carray[i]->marked_for_close &&
- !circuit_stream_is_being_handled(carray[i], 0, MIN_CIRCUITS_HANDLING_STREAM))
+ if (ap_stream_wants_exit_attention(carray[i]))
++n_pending_connections;
}
// log_fn(LOG_DEBUG, "Choosing exit node; %d connections are pending",
@@ -950,11 +958,7 @@ choose_good_exit_server_general(routerlist_t *dir, int need_uptime,
}
n_supported[i] = 0;
for (j = 0; j < n_connections; ++j) { /* iterate over connections */
- if (carray[j]->type != CONN_TYPE_AP ||
- carray[j]->state != AP_CONN_STATE_CIRCUIT_WAIT ||
- carray[j]->marked_for_close ||
- connection_edge_is_rendezvous_stream(carray[j]) ||
- circuit_stream_is_being_handled(carray[j], 0, MIN_CIRCUITS_HANDLING_STREAM))
+ if (!ap_stream_wants_exit_attention(carray[j]))
continue; /* Skip everything but APs in CIRCUIT_WAIT */
if (connection_ap_can_use_exit(carray[j], router)) {
++n_supported[i];