Commit 77a494dd authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

Expunge remaining places where we used "tree" to mean "associative array".


svn:r5490
parent 148a1e96
...@@ -53,10 +53,10 @@ _orconn_circid_entry_hash(orconn_circid_circuit_map_t *a) ...@@ -53,10 +53,10 @@ _orconn_circid_entry_hash(orconn_circid_circuit_map_t *a)
return (((unsigned)a->circ_id)<<16) ^ (unsigned)(uintptr_t)(a->or_conn); return (((unsigned)a->circ_id)<<16) ^ (unsigned)(uintptr_t)(a->or_conn);
} }
static HT_HEAD(orconn_circid_tree, orconn_circid_circuit_map_t) orconn_circid_circuit_map = HT_INITIALIZER(); static HT_HEAD(orconn_circid_map, orconn_circid_circuit_map_t) orconn_circid_circuit_map = HT_INITIALIZER();
HT_PROTOTYPE(orconn_circid_tree, orconn_circid_circuit_map_t, node, HT_PROTOTYPE(orconn_circid_map, orconn_circid_circuit_map_t, node,
_orconn_circid_entry_hash, _orconn_circid_entries_eq); _orconn_circid_entry_hash, _orconn_circid_entries_eq);
HT_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, HT_GENERATE(orconn_circid_map, orconn_circid_circuit_map_t, node,
_orconn_circid_entry_hash, _orconn_circid_entries_eq, 0.6, _orconn_circid_entry_hash, _orconn_circid_entries_eq, 0.6,
malloc, realloc, free); malloc, realloc, free);
...@@ -64,8 +64,6 @@ HT_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node, ...@@ -64,8 +64,6 @@ HT_GENERATE(orconn_circid_tree, orconn_circid_circuit_map_t, node,
* used to improve performance when many cells arrive in a row from the * used to improve performance when many cells arrive in a row from the
* same circuit. * same circuit.
*/ */
/* (We tried using splay trees, but round-robin turned out to make them
* suck.) */
orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL; orconn_circid_circuit_map_t *_last_circid_orconn_ent = NULL;
/** Set the p_conn or n_conn field of a circuit <b>circ</b>, along /** Set the p_conn or n_conn field of a circuit <b>circ</b>, along
...@@ -108,7 +106,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id, ...@@ -108,7 +106,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
if (old_conn) { /* we may need to remove it from the conn-circid map */ if (old_conn) { /* we may need to remove it from the conn-circid map */
search.circ_id = old_id; search.circ_id = old_id;
search.or_conn = old_conn; search.or_conn = old_conn;
found = HT_REMOVE(orconn_circid_tree, &orconn_circid_circuit_map, &search); found = HT_REMOVE(orconn_circid_map, &orconn_circid_circuit_map, &search);
if (found) { if (found) {
tor_free(found); tor_free(found);
} }
...@@ -121,7 +119,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id, ...@@ -121,7 +119,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
/* now add the new one to the conn-circid map */ /* now add the new one to the conn-circid map */
search.circ_id = id; search.circ_id = id;
search.or_conn = conn; search.or_conn = conn;
found = HT_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search); found = HT_FIND(orconn_circid_map, &orconn_circid_circuit_map, &search);
if (found) { if (found) {
found->circuit = circ; found->circuit = circ;
} else { } else {
...@@ -129,7 +127,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id, ...@@ -129,7 +127,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
found->circ_id = id; found->circ_id = id;
found->or_conn = conn; found->or_conn = conn;
found->circuit = circ; found->circuit = circ;
HT_INSERT(orconn_circid_tree, &orconn_circid_circuit_map, found); HT_INSERT(orconn_circid_map, &orconn_circid_circuit_map, found);
} }
++conn->n_circuits; ++conn->n_circuits;
} }
...@@ -397,7 +395,7 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn) ...@@ -397,7 +395,7 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn)
} else { } else {
search.circ_id = circ_id; search.circ_id = circ_id;
search.or_conn = conn; search.or_conn = conn;
found = HT_FIND(orconn_circid_tree, &orconn_circid_circuit_map, &search); found = HT_FIND(orconn_circid_map, &orconn_circid_circuit_map, &search);
_last_circid_orconn_ent = found; _last_circid_orconn_ent = found;
} }
if (found && found->circuit) if (found && found->circuit)
...@@ -410,11 +408,11 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn) ...@@ -410,11 +408,11 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn)
circuit_t *circ; circuit_t *circ;
for (circ=global_circuitlist;circ;circ = circ->next) { for (circ=global_circuitlist;circ;circ = circ->next) {
if (circ->p_conn == conn && circ->p_circ_id == circ_id) { if (circ->p_conn == conn && circ->p_circ_id == circ_id) {
warn(LD_BUG, "circuit matches p_conn, but not in tree (Bug!)"); warn(LD_BUG, "circuit matches p_conn, but not in hash table (Bug!)");
return circ; return circ;
} }
if (circ->n_conn == conn && circ->n_circ_id == circ_id) { if (circ->n_conn == conn && circ->n_circ_id == circ_id) {
warn(LD_BUG, "circuit matches n_conn, but not in tree (Bug!)"); warn(LD_BUG, "circuit matches n_conn, but not in hash table (Bug!)");
return circ; return circ;
} }
} }
......
...@@ -424,8 +424,8 @@ connection_ap_detach_retriable(connection_t *conn, circuit_t *circ) ...@@ -424,8 +424,8 @@ connection_ap_detach_retriable(connection_t *conn, circuit_t *circ)
} }
/** A client-side struct to remember requests to rewrite addresses /** A client-side struct to remember requests to rewrite addresses
* to new addresses. These structs make up a tree, with addressmap * to new addresses. These structs are stored the hash table
* below as its root. * "addressmap" below.
* *
* There are 5 ways to set an address mapping: * There are 5 ways to set an address mapping:
* - A MapAddress command from the controller [permanent] * - A MapAddress command from the controller [permanent]
...@@ -455,10 +455,10 @@ typedef struct { ...@@ -455,10 +455,10 @@ typedef struct {
char *hostname_address; char *hostname_address;
} virtaddress_entry_t; } virtaddress_entry_t;
/** The tree of client-side address rewrite instructions. */ /** A hash table to store client-side address rewrite instructions. */
static strmap_t *addressmap=NULL; static strmap_t *addressmap=NULL;
/** /**
* Tree mapping addresses to which virtual address, if any, we * Table mapping addresses to which virtual address, if any, we
* assigned them to. * assigned them to.
* *
* We maintain the following invariant: if [A,B] is in * We maintain the following invariant: if [A,B] is in
......
...@@ -80,7 +80,7 @@ static void send_resolved_cell(connection_t *conn, uint8_t answer_type); ...@@ -80,7 +80,7 @@ static void send_resolved_cell(connection_t *conn, uint8_t answer_type);
static HT_HEAD(cache_map, cached_resolve_t) cache_root; static HT_HEAD(cache_map, cached_resolve_t) cache_root;
/** Function to compare hashed resolves on their addresses; used to /** Function to compare hashed resolves on their addresses; used to
* implement splay trees. */ * implement hash tables. */
static INLINE int static INLINE int
cached_resolves_eq(cached_resolve_t *a, cached_resolve_t *b) cached_resolves_eq(cached_resolve_t *a, cached_resolve_t *b)
{ {
...@@ -279,7 +279,7 @@ dns_resolve(connection_t *exitconn) ...@@ -279,7 +279,7 @@ dns_resolve(connection_t *exitconn)
/* lower-case exitconn->address, so it's in canonical form */ /* lower-case exitconn->address, so it's in canonical form */
tor_strlower(exitconn->address); tor_strlower(exitconn->address);
/* now check the tree to see if 'address' is already there. */ /* now check the hash table to see if 'address' is already there. */
strlcpy(search.address, exitconn->address, sizeof(search.address)); strlcpy(search.address, exitconn->address, sizeof(search.address));
resolve = HT_FIND(cache_map, &cache_root, &search); resolve = HT_FIND(cache_map, &cache_root, &search);
if (resolve) { /* already there */ if (resolve) { /* already there */
...@@ -536,7 +536,7 @@ dns_purge_resolve(cached_resolve_t *resolve) ...@@ -536,7 +536,7 @@ dns_purge_resolve(cached_resolve_t *resolve)
newest_cached_resolve = tmp; newest_cached_resolve = tmp;
} }
/* remove resolve from the tree */ /* remove resolve from the map */
HT_REMOVE(cache_map, &cache_root, resolve); HT_REMOVE(cache_map, &cache_root, resolve);
tor_free(resolve); tor_free(resolve);
......
...@@ -1036,7 +1036,7 @@ do_main_loop(void) ...@@ -1036,7 +1036,7 @@ do_main_loop(void)
{ {
int loop_result; int loop_result;
dns_init(); /* initialize dns resolve tree, spawn workers if needed */ dns_init(); /* initialize dns resolve map, spawn workers if needed */
handle_signals(1); handle_signals(1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment