[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r11148: help nick work on proposal 108 (tor/trunk/src/or)
Author: arma
Date: 2007-08-16 21:29:58 -0400 (Thu, 16 Aug 2007)
New Revision: 11148
Modified:
tor/trunk/src/or/dirserv.c
tor/trunk/src/or/main.c
tor/trunk/src/or/or.h
tor/trunk/src/or/rephist.c
Log:
help nick work on proposal 108
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2007-08-16 19:32:29 UTC (rev 11147)
+++ tor/trunk/src/or/dirserv.c 2007-08-17 01:29:58 UTC (rev 11148)
@@ -53,8 +53,8 @@
uint32_t addr, uint16_t or_port,
const char *platform, const char *contact,
const char **msg, int should_log);
-static int dirserv_thinks_router_is_reachable(routerinfo_t *router,
- time_t now);
+static void dirserv_set_router_is_running(routerinfo_t *router,
+ time_t now);
static void clear_cached_dir(cached_dir_t *d);
static int dirserv_add_extrainfo(extrainfo_t *ei, const char **msg);
@@ -839,13 +839,23 @@
/** Treat a router as alive if
* - It's me, and I'm not hibernating.
* or - We've found it reachable recently. */
-static int
-dirserv_thinks_router_is_reachable(routerinfo_t *router, time_t now)
+static void
+dirserv_set_router_is_running(routerinfo_t *router, time_t now)
{
+ int answer;
+
if (router_is_me(router) && !we_are_hibernating())
- return 1;
- return get_options()->AssumeReachable ||
- now < router->last_reachable + REACHABLE_TIMEOUT;
+ answer = 1;
+ else
+ answer = get_options()->AssumeReachable ||
+ now < router->last_reachable + REACHABLE_TIMEOUT;
+
+ if (router->is_running && !answer) {
+ /* it was running but now it's not. tell rephist. */
+ rep_hist_note_router_unreachable(router->cache_info.identity_digest, now);
+ }
+
+ router->is_running = answer;
}
/** Return 1 if we're confident that there's a problem with
@@ -892,7 +902,7 @@
{
if (authdir) {
/* Update router status in routerinfo_t. */
- ri->is_running = dirserv_thinks_router_is_reachable(ri, now);
+ dirserv_set_router_is_running(ri, now);
}
if (for_controller == 1 || ri->cache_info.published_on >= cutoff)
smartlist_add(rs_entries, list_single_server_status(ri, ri->is_running));
@@ -1927,7 +1937,7 @@
/* precompute this part, since we need it to decide what "stable"
* means. */
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
- ri->is_running = dirserv_thinks_router_is_reachable(ri, now);
+ dirserv_set_router_is_running(ri, now);
});
dirserv_compute_performance_thresholds(rl);
@@ -2345,7 +2355,7 @@
/* precompute this part, since we need it to decide what "stable"
* means. */
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
- ri->is_running = dirserv_thinks_router_is_reachable(ri, now);
+ dirserv_set_router_is_running(ri, now);
});
dirserv_compute_performance_thresholds(rl);
@@ -2649,6 +2659,7 @@
int as_advertised)
{
routerlist_t *rl = router_get_routerlist();
+ time_t now = time(NULL);
tor_assert(address);
tor_assert(digest_rcvd);
@@ -2659,7 +2670,8 @@
/* correct digest. mark this router reachable! */
log_info(LD_DIRSERV, "Found router %s to be reachable. Yay.",
ri->nickname);
- ri->last_reachable = time(NULL);
+ rep_hist_note_router_reachable(digest_rcvd, now);
+ ri->last_reachable = now;
ri->num_unreachable_notifications = 0;
}
});
@@ -2677,9 +2689,8 @@
* bit over 20 minutes).
*/
void
-dirserv_test_reachability(int try_all)
+dirserv_test_reachability(time_t now, int try_all)
{
- time_t now = time(NULL);
/* XXX decide what to do here; see or-talk thread "purging old router
* information, revocation." -NM
* We can't afford to mess with this in 0.1.2.x. The reason is that
Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c 2007-08-16 19:32:29 UTC (rev 11147)
+++ tor/trunk/src/or/main.c 2007-08-17 01:29:58 UTC (rev 11148)
@@ -929,7 +929,7 @@
if (now % 10 == 0 && (authdir_mode_tests_reachability(options)) &&
!we_are_hibernating()) {
/* try to determine reachability of the other Tor servers */
- dirserv_test_reachability(0);
+ dirserv_test_reachability(now, 0);
}
/** 1d. DOCDOC */
@@ -1322,6 +1322,7 @@
do_main_loop(void)
{
int loop_result;
+ time_t now;
/* initialize dns resolve map, spawn workers if needed */
if (dns_init() < 0) {
@@ -1361,11 +1362,12 @@
if (router_reload_consensus_networkstatus()) {
return -1;
}
- directory_info_has_arrived(time(NULL),1);
+ now = time(NULL);
+ directory_info_has_arrived(now, 1);
if (authdir_mode_tests_reachability(get_options())) {
/* the directory is already here, run startup things */
- dirserv_test_reachability(1);
+ dirserv_test_reachability(now, 1);
}
if (server_mode(get_options())) {
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2007-08-16 19:32:29 UTC (rev 11147)
+++ tor/trunk/src/or/or.h 2007-08-17 01:29:58 UTC (rev 11148)
@@ -2804,7 +2804,7 @@
uint16_t or_port,
const char *digest_rcvd,
int as_advertised);
-void dirserv_test_reachability(int try_all);
+void dirserv_test_reachability(time_t now, int try_all);
int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
int complain);
int dirserv_would_reject_router(routerstatus_t *rs);
@@ -3117,6 +3117,9 @@
int rep_hist_load_state(or_state_t *state, char **err);
void rep_history_clean(time_t before);
+void rep_hist_note_router_reachable(const char *id, time_t when);
+void rep_hist_note_router_unreachable(const char *id, time_t when);
+
time_t rep_hist_downrate_old_runs(time_t now);
double rep_hist_get_stability(const char *id, time_t when);
Modified: tor/trunk/src/or/rephist.c
===================================================================
--- tor/trunk/src/or/rephist.c 2007-08-16 19:32:29 UTC (rev 11147)
+++ tor/trunk/src/or/rephist.c 2007-08-17 01:29:58 UTC (rev 11148)
@@ -262,6 +262,24 @@
hist->changed = when;
}
+/** We have just decided that this router is reachable, meaning
+ * we will give it a "Running" flag for the next while. */
+void
+rep_hist_note_router_reachable(const char *id, time_t when)
+{
+ (void)id;
+ (void)when;
+}
+
+/** We have just decided that this router is unreachable, meaning
+ * we are taking away its "Running" flag. */
+void
+rep_hist_note_router_unreachable(const char *id, time_t when)
+{
+ (void)id;
+ (void)when;
+}
+
/**DOCDOC*/
time_t
rep_hist_downrate_old_runs(time_t now)
@@ -1463,7 +1481,7 @@
hs_usage_list_clear(h->list);
}
-/** Advances to next observation period */
+/** Advances to next observation period. */
static void
hs_usage_advance_current_observation_period(void)
{
@@ -1533,7 +1551,7 @@
}
/** Adds the observation of being requested for a rendezvous service descriptor
-* in our role as HS authoritative directory. */
+ * in our role as HS authoritative directory. */
void
hs_usage_note_fetch_total(const char *service_id, time_t now)
{
@@ -1541,15 +1559,15 @@
}
/** Adds the observation of being requested for a rendezvous service descriptor
-* in our role as HS authoritative directory and being able to answer that
-* request successfully. */
+ * in our role as HS authoritative directory and being able to answer that
+ * request successfully. */
void
hs_usage_note_fetch_successful(const char *service_id, time_t now)
{
hs_usage_add_service_related_observation(fetch_successful, now, service_id);
}
-/** Writes the given circular array to a string */
+/** Writes the given circular array to a string. */
static size_t
hs_usage_format_history(char *buf, size_t len, uint32_t *data)
{
@@ -1574,7 +1592,7 @@
}
/** Writes the complete usage history as hidden service authoritative directory
- * to a string */
+ * to a string. */
static char *
hs_usage_format_statistics(void)
{