[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Split mark-dir-failed-and-retry logic into separate functio...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Split mark-dir-failed-and-retry logic into separate functio...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Mon, 3 Jan 2005 15:07:10 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Mon, 03 Jan 2005 15:07:32 -0500
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv29357/src/or
Modified Files:
connection.c directory.c or.h
Log Message:
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.
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.312
retrieving revision 1.313
diff -u -d -r1.312 -r1.313
--- connection.c 3 Jan 2005 19:51:10 -0000 1.312
+++ connection.c 3 Jan 2005 20:07:07 -0000 1.313
@@ -208,13 +208,7 @@
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);
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -d -r1.183 -r1.184
--- directory.c 3 Jan 2005 17:47:32 -0000 1.183
+++ directory.c 3 Jan 2005 20:07:07 -0000 1.184
@@ -213,6 +213,28 @@
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 @@
/* 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:
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.512
retrieving revision 1.513
diff -u -d -r1.512 -r1.513
--- or.h 31 Dec 2004 21:47:54 -0000 1.512
+++ or.h 3 Jan 2005 20:07:07 -0000 1.513
@@ -1318,6 +1318,7 @@
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 @@
void assert_addr_policy_ok(addr_policy_t *t);
#endif
-