stop fetching descriptors if we're not a dir mirror and we

haven't tried to establish any circuits lately.


svn:r6516
This commit is contained in:
Roger Dingledine
2006-05-30 06:19:06 +00:00
parent 1f0e20806b
commit ae2648fb1c
4 changed files with 23 additions and 4 deletions
+2 -2
View File
@@ -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)
+4 -2
View File
@@ -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);
+11
View File
@@ -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
+6
View File
@@ -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 */