aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-04-08 15:37:15 -0400
committerNick Mathewson <nickm@torproject.org>2014-04-08 15:37:15 -0400
commit689863d0a9432250f2c9a67e3e7ba2c4e5dae4c6 (patch)
treecae635fa01e8cc15f443cd3265cfc1a54bcad14f /src
parentb933fdcc11dd12969acf06d688ebf4730147133e (diff)
parent2d5a7b1842b3dad522166659ff3a88e418f36d13 (diff)
downloadtor-689863d0a9432250f2c9a67e3e7ba2c4e5dae4c6.tar
tor-689863d0a9432250f2c9a67e3e7ba2c4e5dae4c6.tar.gz
Merge branch 'bug2454_025_squashed'
Diffstat (limited to 'src')
-rw-r--r--src/or/circuitstats.c12
-rw-r--r--src/or/main.c13
-rw-r--r--src/or/main.h1
3 files changed, 24 insertions, 2 deletions
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index c093ecd26..e362b1b49 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -12,6 +12,7 @@
#include "config.h"
#include "confparse.h"
#include "control.h"
+#include "main.h"
#include "networkstatus.h"
#include "statefile.h"
@@ -1185,6 +1186,12 @@ circuit_build_times_needs_circuits_now(const circuit_build_times_t *cbt)
}
/**
+ * How long should we be unreachable before we think we need to check if
+ * our published IP address has changed.
+ */
+#define CIRCUIT_TIMEOUT_BEFORE_RECHECK_IP (60*3)
+
+/**
* Called to indicate that the network showed some signs of liveness,
* i.e. we received a cell.
*
@@ -1199,12 +1206,15 @@ circuit_build_times_network_is_live(circuit_build_times_t *cbt)
{
time_t now = approx_time();
if (cbt->liveness.nonlive_timeouts > 0) {
+ time_t time_since_live = now - cbt->liveness.network_last_live;
log_notice(LD_CIRC,
"Tor now sees network activity. Restoring circuit build "
"timeout recording. Network was down for %d seconds "
"during %d circuit attempts.",
- (int)(now - cbt->liveness.network_last_live),
+ (int)time_since_live,
cbt->liveness.nonlive_timeouts);
+ if (time_since_live > CIRCUIT_TIMEOUT_BEFORE_RECHECK_IP)
+ reschedule_descriptor_update_check();
}
cbt->liveness.network_last_live = now;
cbt->liveness.nonlive_timeouts = 0;
diff --git a/src/or/main.c b/src/or/main.c
index feca35c44..86f343750 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1162,6 +1162,18 @@ get_signewnym_epoch(void)
return newnym_epoch;
}
+static time_t time_to_check_descriptor = 0;
+/**
+ * Update our schedule so that we'll check whether we need to update our
+ * descriptor immediately, rather than after up to CHECK_DESCRIPTOR_INTERVAL
+ * seconds.
+ */
+void
+reschedule_descriptor_update_check(void)
+{
+ time_to_check_descriptor = 0;
+}
+
/** Perform regular maintenance tasks. This function gets run once per
* second by second_elapsed_callback().
*/
@@ -1171,7 +1183,6 @@ run_scheduled_events(time_t now)
static time_t last_rotated_x509_certificate = 0;
static time_t time_to_check_v3_certificate = 0;
static time_t time_to_check_listeners = 0;
- static time_t time_to_check_descriptor = 0;
static time_t time_to_download_networkstatus = 0;
static time_t time_to_shrink_memory = 0;
static time_t time_to_try_getting_descriptors = 0;
diff --git a/src/or/main.h b/src/or/main.h
index df302ffa7..a2f03d954 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -50,6 +50,7 @@ void directory_info_has_arrived(time_t now, int from_cache);
void ip_address_changed(int at_interface);
void dns_servers_relaunch_checks(void);
+void reschedule_descriptor_update_check(void);
long get_uptime(void);
unsigned get_signewnym_epoch(void);