diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-01-03 20:07:07 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-01-03 20:07:07 +0000 |
commit | 65c4fa26147998954d371ff50bea7106fb769dc9 (patch) | |
tree | 1aaa3c601e5be036b50f08dfd6840b6c4a938e7a /src/or/directory.c | |
parent | 858eda473674f42261ff3c7e765bf0cc280dd681 (diff) | |
download | tor-65c4fa26147998954d371ff50bea7106fb769dc9.tar.gz tor-65c4fa26147998954d371ff50bea7106fb769dc9.zip |
Split mark-dir-failed-and-retry logic into separate function; make it retry runningrouters as well as directory fetches; note that the do-we-need-to-give-up test is wrong.
svn:r3256
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index c6459cb0ca..c89b2125ce 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -213,6 +213,28 @@ directory_initiate_command_trusted_dir(trusted_dir_server_t *dirserv, NULL, dirserv->digest, purpose, resource, payload, payload_len); } +/** Called when we are unable to complete our connection to a + * directory server: Mark the router as down and try again if possible. + */ +int +connection_dir_connect_failed(connection_t *conn) +{ + router_mark_as_down(conn->identity_digest); /* don't try him again */ + if (conn->purpose == DIR_PURPOSE_FETCH_DIR || + conn->purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) { + /* XXX This should possibly take into account that + * !advertised_server_mode() allows us to use more directory + * servers, and fascistfirewall allows us to use less. + */ + if (!all_trusted_directory_servers_down()) { + log_fn(LOG_INFO,"Giving up on dirserver '%s'; trying another.", conn->address); + directory_get_from_dirserver(conn->purpose, NULL); + } else { + log_fn(LOG_INFO,"Giving up on dirserver '%s'; no more to try.", conn->address); + } + } +} + /** Helper for directory_initiate_command(router|trusted_dir): send the * command to a server whose address is <b>address</b>, whose IP is * <b>addr</b>, whose directory port is <b>dir_port</b>, whose tor version is @@ -282,12 +304,7 @@ directory_initiate_command(const char *address, uint32_t addr, /* then we want to connect directly */ switch (connection_connect(conn, conn->address, addr, dir_port)) { case -1: - router_mark_as_down(conn->identity_digest); /* don't try him again */ - if (purpose == DIR_PURPOSE_FETCH_DIR && - !all_trusted_directory_servers_down()) { - log_fn(LOG_INFO,"Giving up on dirserver '%s'; trying another.", conn->address); - directory_get_from_dirserver(purpose, NULL); - } + connection_dir_connect_failed(conn); connection_free(conn); return; case 1: |