[or-cvs] Correct fix for self-to-self addressmap; simplify replace-o...
Nick Mathewson
nickm at seul.org
Wed Mar 23 05:32:09 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv29573/src/or
Modified Files:
connection_edge.c
Log Message:
Correct fix for self-to-self addressmap; simplify replace-old-entry logic; add missing case.
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -d -r1.303 -r1.304
--- connection_edge.c 23 Mar 2005 02:52:55 -0000 1.303
+++ connection_edge.c 23 Mar 2005 05:32:06 -0000 1.304
@@ -89,6 +89,7 @@
case AP_CONN_STATE_CIRCUIT_WAIT:
case AP_CONN_STATE_CONNECT_WAIT:
case AP_CONN_STATE_RESOLVE_WAIT:
+ case AP_CONN_STATE_CONTROLLER_WAIT:
log_fn(LOG_INFO,"data from edge while in '%s' state. Leaving it on buffer.",
conn_state_to_string[conn->type][conn->state]);
return 0;
@@ -206,6 +207,7 @@
case AP_CONN_STATE_RENDDESC_WAIT:
case AP_CONN_STATE_CIRCUIT_WAIT:
case AP_CONN_STATE_CONNECT_WAIT:
+ case AP_CONN_STATE_CONTROLLER_WAIT:
connection_stop_writing(conn);
return 0;
default:
@@ -544,11 +546,6 @@
addressmap_entry_t *ent;
ent = strmap_get(addressmap, address);
- if (ent && ent->new_address && expires>1) {
- log_fn(LOG_INFO,"Addressmap ('%s' to '%s') not performed, since it's already mapped to '%s'", address, new_address, ent->new_address);
- tor_free(new_address);
- return;
- }
if (!new_address || !strcasecmp(address,new_address)) {
/* Remove the mapping, if any. */
tor_free(new_address);
@@ -558,15 +555,21 @@
}
return;
}
- if (ent && ent->new_address) { /* we'll replace it */
+ if (!ent) { /* make a new one and register it */
+ ent = tor_malloc_zero(sizeof(addressmap_entry_t));
+ strmap_set(addressmap, address, ent);
+ } else if (ent->new_address) { /* we need to clean up the old mapping. */
+ if (expires > 1) {
+ log_fn(LOG_INFO,"Temporary addressmap ('%s' to '%s') not performed, since it's already mapped to '%s'", address, new_address, ent->new_address);
+ tor_free(new_address);
+ return;
+ }
if (address_is_in_virtual_range(ent->new_address)) {
addressmap_virtaddress_remove(address, ent);
}
tor_free(ent->new_address);
- } else if (!ent) { /* make a new one and register it */
- ent = tor_malloc_zero(sizeof(addressmap_entry_t));
- strmap_set(addressmap, address, ent);
- }
+ } /* else { we have an in-progress resolve with no mapping. } */
+
ent->new_address = new_address;
ent->expires = expires;
ent->num_resolve_failures = 0;
More information about the tor-commits
mailing list