summaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-01-17 18:13:09 +0000
committerRoger Dingledine <arma@torproject.org>2005-01-17 18:13:09 +0000
commitd2400a5afd70b009b632b307205273fc25c8cd92 (patch)
tree5a25d9d3a30fb61f43c53387397e8529544775c2 /src/or/circuitlist.c
parent9c8c90ec2f2ae0d83effbaa3a13077dfc9dd975c (diff)
downloadtor-d2400a5afd70b009b632b307205273fc25c8cd92.tar.gz
tor-d2400a5afd70b009b632b307205273fc25c8cd92.zip
Introduce a notion of 'internal' circs, which are chosen without regard
to the exit policy of the last hop. Intro and rendezvous circs must be internal circs, to avoid leaking information. Resolve and connect streams can use internal circs if they want. New circuit pooling algorithm: make sure to have enough circs around to satisfy any predicted ports, and also make sure to have 2 internal circs around if we've required internal circs lately (with high uptime if we've seen that lately). Split NewCircuitPeriod config option into NewCircuitPeriod (30 secs), which describes how often we retry making new circuits if current ones are dirty, and MaxCircuitDirtiness (10 mins), which describes how long we're willing to make use of an already-dirty circuit. Once rendezvous circuits are established, keep using the same circuit as long as you attach a new stream to it at least every 10 minutes. (So web browsing doesn't require you to build new rend circs every 30 seconds.) Cannibalize GENERAL circs to be C_REND, C_INTRO, S_INTRO, and S_REND circ as necessary, if there are any completed ones lying around when we try to launch one. Re-instate the ifdef's to use version-0 style introduce cells, since there was yet another bug in handling version-1 style. We'll try switching over again after 0.0.9 is obsolete. Bugfix: when choosing an exit node for a new non-internal circ, don't take into account whether it'll be useful for any pending x.onion addresses -- it won't. Bugfix: we weren't actually publishing the hidden service descriptor when it became dirty. So we only published it every 20 minutes or so, which means when you first start your Tor, the hidden service will seem broken. svn:r3360
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 11c7be3e80..643e360c35 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -292,41 +292,29 @@ circuit_t *circuit_get_rendezvous(const char *cookie)
return NULL;
}
-/** Count the number of circs originating here that aren't open, and
- * that have the specified <b>purpose</b>. */
-int circuit_count_building(uint8_t purpose) {
- circuit_t *circ;
- int num=0;
-
- for (circ=global_circuitlist;circ;circ = circ->next) {
- if (CIRCUIT_IS_ORIGIN(circ) &&
- circ->state != CIRCUIT_STATE_OPEN &&
- circ->purpose == purpose &&
- !circ->marked_for_close)
- num++;
- }
- return num;
-}
-
-/** Return the circuit that is open, has specified <b>purpose</b>,
- * has a timestamp_dirty value of 0, and was created most recently,
- * or NULL if no circuit fits this description.
+/** Return a circuit that is open, has specified <b>purpose</b>,
+ * has a timestamp_dirty value of 0, and is uptime/capacity/internal
+ * if required; or NULL if no circuit fits this description.
*/
circuit_t *
-circuit_get_youngest_clean_open(uint8_t purpose) {
+circuit_get_clean_open(uint8_t purpose, int need_uptime,
+ int need_capacity, int internal) {
circuit_t *circ;
- circuit_t *youngest=NULL;
- for (circ=global_circuitlist;circ;circ = circ->next) {
+ log_fn(LOG_DEBUG,"Hunting for a circ to cannibalize: purpose %d, uptime %d, capacity %d, internal %d", purpose, need_uptime, need_capacity, internal);
+
+ for (circ=global_circuitlist; circ; circ = circ->next) {
if (CIRCUIT_IS_ORIGIN(circ) &&
circ->state == CIRCUIT_STATE_OPEN &&
!circ->marked_for_close &&
circ->purpose == purpose &&
!circ->timestamp_dirty &&
- (!youngest || youngest->timestamp_created < circ->timestamp_created))
- youngest = circ;
+ (!need_uptime || circ->build_state->need_uptime) &&
+ (!need_capacity || circ->build_state->need_capacity) &&
+ (!internal || circ->build_state->is_internal))
+ return circ;
}
- return youngest;
+ return NULL;
}
/** Mark <b>circ</b> to be closed next time we call