summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-05-30 06:19:06 +0000
committerRoger Dingledine <arma@torproject.org>2006-05-30 06:19:06 +0000
commitae2648fb1c1eed93a9cc2c7480c22516f1f33d56 (patch)
treeb400a035d775b179eba547fbaea9522cc9efb2e3 /src
parent1f0e20806b442153d439060b278a1da1b36d2216 (diff)
downloadtor-ae2648fb1c1eed93a9cc2c7480c22516f1f33d56.tar.gz
tor-ae2648fb1c1eed93a9cc2c7480c22516f1f33d56.zip
stop fetching descriptors if we're not a dir mirror and we
haven't tried to establish any circuits lately. svn:r6516
Diffstat (limited to 'src')
-rw-r--r--src/or/circuituse.c4
-rw-r--r--src/or/or.h6
-rw-r--r--src/or/rephist.c11
-rw-r--r--src/or/routerlist.c6
4 files changed, 23 insertions, 4 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 2aec912c17..0cd5ee41ba 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -542,8 +542,8 @@ circuit_about_to_close_connection(connection_t *conn)
} /* end switch */
}
-/** Find each circuit that has been dirty for too long, and has
- * no streams on it: mark it for close.
+/** Find each circuit that has been unused for too long, or dirty
+ * for too long and has no streams on it: mark it for close.
*/
static void
circuit_expire_old_circuits(time_t now)
diff --git a/src/or/or.h b/src/or/or.h
index 071b83fdd5..6201e825ec 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -473,6 +473,7 @@ typedef enum {
#define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
#define RESOLVED_TYPE_ERROR 0xF1
+/* XXX We should document the meaning of these. */
#define END_CIRC_AT_ORIGIN -1
#define _END_CIRC_REASON_MIN 0
#define END_CIRC_REASON_NONE 0
@@ -2084,6 +2085,8 @@ void rep_hist_note_bytes_read(int num_bytes, time_t when);
void rep_hist_note_bytes_written(int num_bytes, time_t when);
int rep_hist_bandwidth_assess(void);
char *rep_hist_get_bandwidth_lines(void);
+void rep_hist_update_state(or_state_t *state);
+int rep_hist_load_state(or_state_t *state, char **err);
void rep_history_clean(time_t before);
void rep_hist_note_used_port(uint16_t port, time_t now);
@@ -2094,8 +2097,7 @@ void rep_hist_note_used_internal(time_t now, int need_uptime,
int rep_hist_get_predicted_internal(time_t now, int *need_uptime,
int *need_capacity);
-void rep_hist_update_state(or_state_t *state);
-int rep_hist_load_state(or_state_t *state, char **err);
+int rep_hist_circbuilding_dormant(void);
void rep_hist_free_all(void);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 0790084597..d31161ca07 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -751,6 +751,8 @@ rep_hist_load_state(or_state_t *state, char **err)
return 0;
}
+/*********************************************************************/
+
/** A list of port numbers that have been used recently. */
static smartlist_t *predicted_ports_list=NULL;
/** The corresponding most recently used time for each port. */
@@ -912,6 +914,15 @@ rep_hist_get_predicted_internal(time_t now, int *need_uptime,
return 1;
}
+/** Return 1 if we have no need for circuits currently, else return 0. */
+int
+rep_hist_circbuilding_dormant(void)
+{
+ if (predicted_ports_list || predicted_internal_time)
+ return 0; /* nothing used lately. */
+ return 1;
+}
+
/** Free all storage held by the OR/link history caches, by the
* bandwidth history arrays, or by the port history. */
void
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 966ccb9701..6d56555e4b 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3435,6 +3435,12 @@ update_router_descriptor_client_downloads(time_t now)
"Called router_descriptor_client_downloads() on a dir mirror?");
}
+ if (rep_hist_circbuilding_dormant()) {
+ log_info(LD_CIRC, "Skipping descriptor downloads: we haven't need "
+ "any circuits lately.");
+ return;
+ }
+
/* XXX here's another magic 2 that probably should be replaced
* by <= smartlist_len(trusted_dir_servers)/2
* or by a function returning same. -- weasel */