diff options
-rw-r--r-- | src/or/circuitbuild.c | 11 | ||||
-rw-r--r-- | src/or/connection.c | 5 | ||||
-rw-r--r-- | src/or/connection_or.c | 4 | ||||
-rw-r--r-- | src/or/directory.c | 2 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/routerlist.c | 16 |
6 files changed, 23 insertions, 17 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 0ed3e84a13..d0d2279a19 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -1410,19 +1410,20 @@ count_acceptable_routers(smartlist_t *routers) n = smartlist_len(routers); for (i=0;i<n;i++) { r = smartlist_get(routers, i); -// log_fn(LOG_DEBUG,"Contemplating whether router %d (%s) is a new option.", -// i, r->nickname); +// log_debug(LD_CIRC, +// "Contemplating whether router %d (%s) is a new option.", +// i, r->nickname); if (r->is_running == 0) { -// log_fn(LOG_DEBUG,"Nope, the directory says %d is not running.",i); +// log_debug(LD_CIRC,"Nope, the directory says %d is not running.",i); goto next_i_loop; } if (r->is_verified == 0) { -// log_fn(LOG_DEBUG,"Nope, the directory says %d is not verified.",i); +// log_debug(LD_CIRC,"Nope, the directory says %d is not verified.",i); /* XXXX009 But unverified routers *are* sometimes acceptable. */ goto next_i_loop; } num++; -// log_fn(LOG_DEBUG,"I like %d. num_acceptable_routers now %d.",i, num); +// log_debug(LD_CIRC,"I like %d. num_acceptable_routers now %d.",i, num); next_i_loop: ; /* C requires an explicit statement after the label */ } diff --git a/src/or/connection.c b/src/or/connection.c index f9e93a75e4..dc07d3e84d 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -348,6 +348,7 @@ connection_about_to_close_connection(connection_t *conn) if (connection_or_nonopen_was_started_here(conn)) { rep_hist_note_connect_failed(conn->identity_digest, time(NULL)); entry_guard_set_status(conn->identity_digest, 0); + router_set_status(conn->identity_digest, 0); control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED); } } else if (conn->hold_open_until_flushed) { @@ -1425,11 +1426,11 @@ connection_handle_write(connection_t *conn) connection_close_immediate(conn); connection_mark_for_close(conn); - /* it's safe to pass OPs to router_mark_as_down(), since it just + /* it's safe to pass OPs to router_set_status(), since it just * ignores unrecognized routers */ if (conn->type == CONN_TYPE_OR && !get_options()->HttpsProxy) - router_mark_as_down(conn->identity_digest); + router_set_status(conn->identity_digest, 0); return -1; } else { return 0; /* no change, see if next time is better */ diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 2710329399..7fd717717f 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -462,8 +462,8 @@ connection_or_connect(uint32_t addr, uint16_t port, const char *id_digest) * an https proxy, our https proxy is down. Don't blame the * Tor server. */ if (!options->HttpsProxy) { - router_mark_as_down(conn->identity_digest); entry_guard_set_status(conn->identity_digest, 0); + router_set_status(conn->identity_digest, 0); } control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED); connection_free(conn); @@ -637,6 +637,7 @@ connection_or_check_valid_handshake(connection_t *conn, char *digest_rcvd) "but got %s", conn->address, conn->port, expected, seen); entry_guard_set_status(conn->identity_digest, 0); + router_set_status(conn->identity_digest, 0); control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED); as_advertised = 0; } @@ -703,6 +704,7 @@ connection_tls_finish_handshake(connection_t *conn) /* pending circs get closed in circuit_about_to_close_connection() */ return -1; } + router_set_status(conn->identity_digest, 1); } connection_watch_events(conn, EV_READ); circuit_n_conn_done(conn, 1); /* send the pending creates, if any. */ diff --git a/src/or/directory.c b/src/or/directory.c index 6565e58171..538cbc6a3f 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -310,7 +310,7 @@ connection_dir_request_failed(connection_t *conn) { if (router_digest_is_me(conn->identity_digest)) return; /* this was a test fetch. don't retry. */ - router_mark_as_down(conn->identity_digest); /* don't try him again */ + router_set_status(conn->identity_digest, 0); /* don't try him again */ if (conn->purpose == DIR_PURPOSE_FETCH_DIR || conn->purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) { log_info(LD_DIR, "Giving up on directory server at '%s:%d'; retrying", diff --git a/src/or/or.h b/src/or/or.h index d51b566a31..5486189a92 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2323,7 +2323,7 @@ void routerstatus_free(routerstatus_t *routerstatus); void networkstatus_free(networkstatus_t *networkstatus); void routerlist_free_all(void); routerinfo_t *routerinfo_copy(const routerinfo_t *router); -void router_mark_as_down(const char *digest); +void router_set_status(const char *digest, int up); void routerlist_remove_old_routers(void); void networkstatus_list_clean(time_t now); int router_add_to_routerlist(routerinfo_t *router, const char **msg, diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 739f0b5623..d3dfcd6a36 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1409,9 +1409,10 @@ routerlist_reset_warnings(void) have_warned_about_new_version = 0; } -/** Mark the router with ID <b>digest</b> as non-running in our routerlist. */ +/** Mark the router with ID <b>digest</b> as running or non-running + * in our routerlist. */ void -router_mark_as_down(const char *digest) +router_set_status(const char *digest, int up) { routerinfo_t *router; local_routerstatus_t *status; @@ -1419,19 +1420,20 @@ router_mark_as_down(const char *digest) SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, d, if (!memcmp(d->digest, digest, DIGEST_LEN)) - d->is_running = 0); + d->is_running = up); router = router_get_by_digest(digest); if (router) { - log_debug(LD_DIR,"Marking router '%s' as down.",router->nickname); - if (router_is_me(router) && !we_are_hibernating()) + log_debug(LD_DIR,"Marking router '%s' as %s.", + router->nickname, up ? "up" : "down"); + if (!up && router_is_me(router) && !we_are_hibernating()) log_warn(LD_NET, "We just marked ourself as down. Are your external " "addresses reachable?"); - router->is_running = 0; + router->is_running = up; } status = router_get_combined_status_by_digest(digest); if (status) { - status->status.is_running = 0; + status->status.is_running = up; } } |