start to clean up r13250: retry v2 renddesc fetches when we

fail to reach the dirserver too.


svn:r13251
This commit is contained in:
Roger Dingledine 2008-01-24 04:45:30 +00:00
parent 6b1374556e
commit c973eb5e23
2 changed files with 15 additions and 24 deletions

View File

@ -468,10 +468,12 @@ connection_about_to_close_connection(connection_t *conn)
/* It's a directory connection and connecting or fetching /* It's a directory connection and connecting or fetching
* failed: forget about this router, and maybe try again. */ * failed: forget about this router, and maybe try again. */
connection_dir_request_failed(dir_conn); connection_dir_request_failed(dir_conn);
// XXX if it's rend desc we may want to retry -RD
} }
/* if we were trying to fetch a rend desc, retry as needed */
if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC) if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC)
rend_client_desc_here(dir_conn->rend_query); /* give it a try */ rend_client_desc_here(dir_conn->rend_query);
if (conn->purpose == DIR_PURPOSE_FETCH_RENDDESC_V2)
rend_client_refetch_v2_renddesc(dir_conn->rend_query);
break; break;
case CONN_TYPE_OR: case CONN_TYPE_OR:
or_conn = TO_OR_CONN(conn); or_conn = TO_OR_CONN(conn);

View File

@ -1763,13 +1763,11 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
case 200: case 200:
if (rend_cache_store(body, body_len, 0) < 0) { if (rend_cache_store(body, body_len, 0) < 0) {
log_warn(LD_REND,"Failed to fetch rendezvous descriptor."); log_warn(LD_REND,"Failed to fetch rendezvous descriptor.");
/* alice's ap_stream will notice when connection_mark_for_close /* Any pending rendezvous attempts will notice when
* cleans it up */ * connection_about_to_close_connection()
/*XXXX020 maybe retry quickly; timeout takes a while. */ * cleans this dir conn up. */
/* This would require some kind of book-keeping which directories /* We could retry. But since v0 descriptors are going out of
* have been requested and which not. As directory servers are * style, it isn't worth the hassle. We'll do better in v2. */
* rather reliable, this should not be necessary, in constrast to
* v2 hidden service directories. -KL */
} else { } else {
/* success. notify pending connections about this. */ /* success. notify pending connections about this. */
conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC; conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
@ -1777,13 +1775,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
} }
break; break;
case 404: case 404:
/* not there. pending connections will be notified when /* Not there. Pending connections will be notified when
* connection_mark_for_close cleans it up. */ * connection_about_to_close_connection() cleans this conn up. */
/*XXXX020 maybe retry quickly; timeout takes a while. */
/* This would require some kind of book-keeping which directories
* have been requested and which not. As directory servers are
* rather reliable, this should not be necessary, in constrast to
* v2 hidden service directories. -KL */
break; break;
case 400: case 400:
log_warn(LD_REND, log_warn(LD_REND,
@ -1808,9 +1801,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
if (rend_cache_store_v2_desc_as_client(body, NULL) < 0) { if (rend_cache_store_v2_desc_as_client(body, NULL) < 0) {
log_warn(LD_REND,"Fetching v2 rendezvous descriptor failed. " log_warn(LD_REND,"Fetching v2 rendezvous descriptor failed. "
"Retrying at another directory."); "Retrying at another directory.");
/* alice's ap_stream will notice when connection_mark_for_close /* We'll retry when connection_about_to_close_connection()
* cleans it up */ * cleans this dir conn up. */
rend_client_refetch_v2_renddesc(conn->rend_query);
} else { } else {
/* success. notify pending connections about this. */ /* success. notify pending connections about this. */
log_info(LD_REND, "Successfully fetched rendezvous descriptor."); log_info(LD_REND, "Successfully fetched rendezvous descriptor.");
@ -1819,18 +1811,16 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
} }
break; break;
case 404: case 404:
/* not there. pending connections will be notified when /* Not there. We'll retry when
* connection_mark_for_close cleans it up. */ * connection_about_to_close_connection() cleans this conn up. */
log_info(LD_REND,"Fetching v2 rendezvous descriptor failed: " log_info(LD_REND,"Fetching v2 rendezvous descriptor failed: "
"Retrying at another directory."); "Retrying at another directory.");
rend_client_refetch_v2_renddesc(conn->rend_query);
break; break;
case 400: case 400:
log_warn(LD_REND, "Fetching v2 rendezvous descriptor failed: " log_warn(LD_REND, "Fetching v2 rendezvous descriptor failed: "
"http status 400 (%s). Dirserver didn't like our " "http status 400 (%s). Dirserver didn't like our "
"v2 rendezvous query? Retrying at another directory.", "v2 rendezvous query? Retrying at another directory.",
escaped(reason)); escaped(reason));
rend_client_refetch_v2_renddesc(conn->rend_query);
break; break;
default: default:
log_warn(LD_REND, "Fetching v2 rendezvous descriptor failed: " log_warn(LD_REND, "Fetching v2 rendezvous descriptor failed: "
@ -1839,7 +1829,6 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
"Retrying at another directory.", "Retrying at another directory.",
status_code, escaped(reason), conn->_base.address, status_code, escaped(reason), conn->_base.address,
conn->_base.port); conn->_base.port);
rend_client_refetch_v2_renddesc(conn->rend_query);
break; break;
} }
} }