after failing from resolve failed or misc, reset the num failures.

svn:r4780
This commit is contained in:
Roger Dingledine 2005-08-15 03:35:15 +00:00
parent f57d062d9c
commit 3728011f36
3 changed files with 17 additions and 2 deletions

View File

@ -652,8 +652,7 @@ addressmap_register(const char *address, char *new_address, time_t expires)
int
client_dns_incr_failures(const char *address)
{
addressmap_entry_t *ent;
ent = strmap_get(addressmap,address);
addressmap_entry_t *ent = strmap_get(addressmap, address);
if (!ent) {
ent = tor_malloc_zero(sizeof(addressmap_entry_t));
ent->expires = time(NULL)+MAX_DNS_ENTRY_AGE;
@ -665,6 +664,19 @@ client_dns_incr_failures(const char *address)
return ent->num_resolve_failures;
}
/** If <b>address</b> is in the client dns addressmap, reset
* the number of resolve failures we have on record for it.
* This is used when we fail a stream because it won't resolve:
* otherwise future attempts on that address will only try once.
*/
void
client_dns_clear_failures(const char *address)
{
addressmap_entry_t *ent = strmap_get(addressmap, address);
if (ent)
ent->num_resolve_failures = 0;
}
/** Record the fact that <b>address</b> resolved to <b>val</b>.
* We can now use this in subsequent streams via addressmap_rewrite()
* so we can more correctly choose an exit that will allow <b>address</b>.

View File

@ -1490,6 +1490,7 @@ void addressmap_rewrite(char *address, size_t maxlen);
int addressmap_already_mapped(const char *address);
void addressmap_register(const char *address, char *new_address, time_t expires);
int client_dns_incr_failures(const char *address);
void client_dns_clear_failures(const char *address);
void client_dns_set_addressmap(const char *address, uint32_t val, const char *exitname);
const char *addressmap_register_virtual_address(int type, char *new_address);
void addressmap_get_mappings(smartlist_t *sl, time_t min_expires, time_t max_expires);

View File

@ -678,6 +678,8 @@ connection_edge_process_end_not_open(
} else {
log_fn(LOG_NOTICE,"Have tried resolving address '%s' at %d different places. Giving up.",
safe_str(conn->socks_request->address), MAX_RESOLVE_FAILURES);
/* clear the failures, so it will have a full try next time */
client_dns_clear_failures(conn->socks_request->address);
}
break;
case END_STREAM_REASON_HIBERNATING: