summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2010-09-23 22:41:01 -0400
committerRoger Dingledine <arma@torproject.org>2010-09-28 19:10:23 -0400
commitbb22360bad4d19483ff488c9e4a0eae8616fcd81 (patch)
tree005c37780ec6ac7f0702e223f2a28ed71c25aea1
parent8bac1885729ba995397f673575ed58bbb0d698a8 (diff)
downloadtor-bb22360bad4d19483ff488c9e4a0eae8616fcd81.tar.gz
tor-bb22360bad4d19483ff488c9e4a0eae8616fcd81.zip
optimistically retry EntryNodes on socks request
We used to mark all our known bridges up when they're all down and we get a new socks request. Now do that when we've set EntryNodes too.
-rw-r--r--src/or/circuitbuild.c29
-rw-r--r--src/or/circuitbuild.h4
-rw-r--r--src/or/circuituse.c8
3 files changed, 24 insertions, 17 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 90ae92a451..a14ab6a46b 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -4583,24 +4583,27 @@ any_pending_bridge_descriptor_fetches(void)
return 0;
}
-/** Return 1 if we have at least one descriptor for a bridge and
- * all descriptors we know are down. Else return 0. If <b>act</b> is
- * 1, then mark the down bridges up; else just observe and report. */
+/** Return 1 if we have at least one descriptor for an entry guard
+ * (bridge or member of EntryNodes) and all descriptors we know are
+ * down. Else return 0. If <b>act</b> is 1, then mark the down guards
+ * up; else just observe and report. */
static int
-bridges_retry_helper(int act)
+entries_retry_helper(or_options_t *options, int act)
{
routerinfo_t *ri;
int any_known = 0;
int any_running = 0;
+ int purpose = options->UseBridges ?
+ ROUTER_PURPOSE_BRIDGE : ROUTER_PURPOSE_GENERAL;
if (!entry_guards)
entry_guards = smartlist_create();
SMARTLIST_FOREACH(entry_guards, entry_guard_t *, e,
{
ri = router_get_by_digest(e->identity);
- if (ri && ri->purpose == ROUTER_PURPOSE_BRIDGE) {
+ if (ri && ri->purpose == purpose) {
any_known = 1;
if (ri->is_running)
- any_running = 1; /* some bridge is both known and running */
+ any_running = 1; /* some entry is both known and running */
else if (act) { /* mark it for retry */
ri->is_running = 1;
e->can_retry = 1;
@@ -4613,19 +4616,21 @@ bridges_retry_helper(int act)
return any_known && !any_running;
}
-/** Do we know any descriptors for our bridges, and are they all
- * down? */
+/** Do we know any descriptors for our bridges / entrynodes, and are
+ * all the ones we have descriptors for down? */
int
-bridges_known_but_down(void)
+entries_known_but_down(or_options_t *options)
{
- return bridges_retry_helper(0);
+ tor_assert(entry_list_is_constrained(options));
+ return entries_retry_helper(options, 0);
}
/** Mark all down known bridges up. */
void
-bridges_retry_all(void)
+entries_retry_all(or_options_t *options)
{
- bridges_retry_helper(1);
+ tor_assert(entry_list_is_constrained(options));
+ entries_retry_helper(options, 1);
}
/** Release all storage held by the list of entry guards and related
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index 6cc461c98d..033dd79c4c 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -72,8 +72,8 @@ void fetch_bridge_descriptors(or_options_t *options, time_t now);
void learned_bridge_descriptor(routerinfo_t *ri, int from_cache);
int any_bridge_descriptors_known(void);
int any_pending_bridge_descriptor_fetches(void);
-int bridges_known_but_down(void);
-void bridges_retry_all(void);
+int entries_known_but_down(or_options_t *options);
+void entries_retry_all(or_options_t *options);
void entry_guards_free_all(void);
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index e9335b18d6..ee1705b4c9 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1192,11 +1192,13 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
int severity = LOG_NOTICE;
/* FFFF if this is a tunneled directory fetch, don't yell
* as loudly. the user doesn't even know it's happening. */
- if (options->UseBridges && bridges_known_but_down()) {
+ if (entry_list_is_constrained(options) &&
+ entries_known_but_down(options)) {
log_fn(severity, LD_APP|LD_DIR,
"Application request when we haven't used client functionality "
- "lately. Optimistically trying known bridges again.");
- bridges_retry_all();
+ "lately. Optimistically trying known %s again.",
+ options->UseBridges ? "bridges" : "entrynodes");
+ entries_retry_all(options);
} else if (!options->UseBridges || any_bridge_descriptors_known()) {
log_fn(severity, LD_APP|LD_DIR,
"Application request when we haven't used client functionality "