Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
77a494dd
Commit
77a494dd
authored
Dec 03, 2005
by
Nick Mathewson
🥄
Browse files
Expunge remaining places where we used "tree" to mean "associative array".
svn:r5490
parent
148a1e96
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/or/circuitlist.c
View file @
77a494dd
...
...
@@ -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
);
}
static
HT_HEAD
(
orconn_circid_
tree
,
orconn_circid_circuit_map_t
)
orconn_circid_circuit_map
=
HT_INITIALIZER
();
HT_PROTOTYPE
(
orconn_circid_
tree
,
orconn_circid_circuit_map_t
,
node
,
static
HT_HEAD
(
orconn_circid_
map
,
orconn_circid_circuit_map_t
)
orconn_circid_circuit_map
=
HT_INITIALIZER
();
HT_PROTOTYPE
(
orconn_circid_
map
,
orconn_circid_circuit_map_t
,
node
,
_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
,
malloc
,
realloc
,
free
);
...
...
@@ -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
* 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
;
/** 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,
if
(
old_conn
)
{
/* we may need to remove it from the conn-circid map */
search
.
circ_id
=
old_id
;
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
)
{
tor_free
(
found
);
}
...
...
@@ -121,7 +119,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
/* now add the new one to the conn-circid map */
search
.
circ_id
=
id
;
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
)
{
found
->
circuit
=
circ
;
}
else
{
...
...
@@ -129,7 +127,7 @@ circuit_set_circid_orconn(circuit_t *circ, uint16_t id,
found
->
circ_id
=
id
;
found
->
or_conn
=
conn
;
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
;
}
...
...
@@ -397,7 +395,7 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn)
}
else
{
search
.
circ_id
=
circ_id
;
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
;
}
if
(
found
&&
found
->
circuit
)
...
...
@@ -410,11 +408,11 @@ circuit_get_by_circid_orconn_impl(uint16_t circ_id, connection_t *conn)
circuit_t
*
circ
;
for
(
circ
=
global_circuitlist
;
circ
;
circ
=
circ
->
next
)
{
if
(
circ
->
p_conn
==
conn
&&
circ
->
p_circ_id
==
circ_id
)
{
warn
(
LD_BUG
,
"circuit matches p_conn, but not in
tre
e (Bug!)"
);
warn
(
LD_BUG
,
"circuit matches p_conn, but not in
hash tabl
e (Bug!)"
);
return
circ
;
}
if
(
circ
->
n_conn
==
conn
&&
circ
->
n_circ_id
==
circ_id
)
{
warn
(
LD_BUG
,
"circuit matches n_conn, but not in
tre
e (Bug!)"
);
warn
(
LD_BUG
,
"circuit matches n_conn, but not in
hash tabl
e (Bug!)"
);
return
circ
;
}
}
...
...
src/or/connection_edge.c
View file @
77a494dd
...
...
@@ -424,8 +424,8 @@ connection_ap_detach_retriable(connection_t *conn, circuit_t *circ)
}
/** A client-side struct to remember requests to rewrite addresses
* to new addresses. These structs
make up a tree, with addressmap
*
below as its root
.
* to new addresses. These structs
are stored the hash table
*
"addressmap" below
.
*
* There are 5 ways to set an address mapping:
* - A MapAddress command from the controller [permanent]
...
...
@@ -455,10 +455,10 @@ typedef struct {
char
*
hostname_address
;
}
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
;
/**
* T
re
e mapping addresses to which virtual address, if any, we
* T
abl
e mapping addresses to which virtual address, if any, we
* assigned them to.
*
* We maintain the following invariant: if [A,B] is in
...
...
src/or/dns.c
View file @
77a494dd
...
...
@@ -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
;
/** Function to compare hashed resolves on their addresses; used to
* implement
splay tre
es. */
* implement
hash tabl
es. */
static
INLINE
int
cached_resolves_eq
(
cached_resolve_t
*
a
,
cached_resolve_t
*
b
)
{
...
...
@@ -279,7 +279,7 @@ dns_resolve(connection_t *exitconn)
/* lower-case exitconn->address, so it's in canonical form */
tor_strlower
(
exitconn
->
address
);
/* now check the
tre
e to see if 'address' is already there. */
/* now check the
hash tabl
e to see if 'address' is already there. */
strlcpy
(
search
.
address
,
exitconn
->
address
,
sizeof
(
search
.
address
));
resolve
=
HT_FIND
(
cache_map
,
&
cache_root
,
&
search
);
if
(
resolve
)
{
/* already there */
...
...
@@ -536,7 +536,7 @@ dns_purge_resolve(cached_resolve_t *resolve)
newest_cached_resolve
=
tmp
;
}
/* remove resolve from the
tree
*/
/* remove resolve from the
map
*/
HT_REMOVE
(
cache_map
,
&
cache_root
,
resolve
);
tor_free
(
resolve
);
...
...
src/or/main.c
View file @
77a494dd
...
...
@@ -1036,7 +1036,7 @@ do_main_loop(void)
{
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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment