mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
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
This commit is contained in:
parent
858eda4736
commit
65c4fa2614
@ -208,13 +208,7 @@ void connection_about_to_close_connection(connection_t *conn)
|
||||
if (conn->state == DIR_CONN_STATE_CONNECTING) {
|
||||
/* it's a directory server and connecting failed: forget about
|
||||
this router */
|
||||
router_mark_as_down(conn->identity_digest);
|
||||
if (conn->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(DIR_PURPOSE_FETCH_DIR, NULL);
|
||||
}
|
||||
connection_dir_connect_failed(conn);
|
||||
}
|
||||
if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC)
|
||||
rend_client_desc_fetched(conn->rend_query, 0);
|
||||
|
@ -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:
|
||||
|
@ -1318,6 +1318,7 @@ int connection_dir_reached_eof(connection_t *conn);
|
||||
int connection_dir_process_inbuf(connection_t *conn);
|
||||
int connection_dir_finished_flushing(connection_t *conn);
|
||||
int connection_dir_finished_connecting(connection_t *conn);
|
||||
int connection_dir_failed(connection_t *conn);
|
||||
void parse_dir_policy(void);
|
||||
|
||||
/********************************* dirserv.c ***************************/
|
||||
@ -1704,4 +1705,3 @@ int tor_version_compare(tor_version_t *a, tor_version_t *b);
|
||||
void assert_addr_policy_ok(addr_policy_t *t);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user