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
ZerXes
Tor
Commits
9c66e2bf
Commit
9c66e2bf
authored
Dec 12, 2003
by
Roger Dingledine
Browse files
if >=2 circs are being built that handle a given stream,
no need to have new circs handle it too. svn:r896
parent
d23c66b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/or/circuit.c
View file @
9c66e2bf
...
...
@@ -275,6 +275,26 @@ int circuit_count_building(void) {
return
num
;
}
#define MIN_CIRCUITS_HANDLING_STREAM 2
/* return 1 if at least MIN_CIRCUITS_HANDLING_STREAM non-open circuits
* will have an acceptable exit node for conn. Else return 0.
*/
int
circuit_stream_is_being_handled
(
connection_t
*
conn
)
{
circuit_t
*
circ
;
routerinfo_t
*
exitrouter
;
int
num
=
0
;
for
(
circ
=
global_circuitlist
;
circ
;
circ
=
circ
->
next
)
{
if
(
circ
->
cpath
&&
circ
->
state
!=
CIRCUIT_STATE_OPEN
)
{
exitrouter
=
router_get_by_nickname
(
circ
->
build_state
->
chosen_exit
);
if
(
exitrouter
&&
connection_ap_can_use_exit
(
conn
,
exitrouter
)
>=
0
)
if
(
++
num
>=
MIN_CIRCUITS_HANDLING_STREAM
)
return
1
;
}
}
return
0
;
}
int
circuit_deliver_relay_cell
(
cell_t
*
cell
,
circuit_t
*
circ
,
int
cell_direction
,
crypt_path_t
*
layer_hint
)
{
connection_t
*
conn
=
NULL
;
...
...
src/or/onion.c
View file @
9c66e2bf
...
...
@@ -233,7 +233,8 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
for
(
i
=
0
;
i
<
n_connections
;
++
i
)
{
if
(
carray
[
i
]
->
type
==
CONN_TYPE_AP
&&
carray
[
i
]
->
state
==
AP_CONN_STATE_CIRCUIT_WAIT
&&
!
carray
[
i
]
->
marked_for_close
)
!
carray
[
i
]
->
marked_for_close
&&
!
circuit_stream_is_being_handled
(
carray
[
i
]))
++
n_pending_connections
;
}
log_fn
(
LOG_DEBUG
,
"Choosing exit node; %d connections are pending"
,
...
...
@@ -265,7 +266,8 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
for
(
j
=
0
;
j
<
n_connections
;
++
j
)
{
/* iterate over connections */
if
(
carray
[
j
]
->
type
!=
CONN_TYPE_AP
||
carray
[
j
]
->
state
!=
AP_CONN_STATE_CIRCUIT_WAIT
||
carray
[
j
]
->
marked_for_close
)
carray
[
j
]
->
marked_for_close
||
circuit_stream_is_being_handled
(
carray
[
j
]))
continue
;
/* Skip everything but APs in CIRCUIT_WAIT */
switch
(
connection_ap_can_use_exit
(
carray
[
j
],
dir
->
routers
[
i
]))
{
...
...
src/or/or.h
View file @
9c66e2bf
...
...
@@ -517,6 +517,7 @@ circuit_t *circuit_get_newest(connection_t *conn, int must_be_open);
void
circuit_expire_building
(
void
);
int
circuit_count_building
(
void
);
int
circuit_stream_is_being_handled
(
connection_t
*
conn
);
int
circuit_deliver_relay_cell
(
cell_t
*
cell
,
circuit_t
*
circ
,
int
cell_direction
,
crypt_path_t
*
layer_hint
);
...
...
src/or/routerlist.c
View file @
9c66e2bf
...
...
@@ -698,7 +698,7 @@ router_get_list_from_string_impl(const char **s, routerlist_t **dest,
/* Helper function: reads a single router entry from *s, and advances
*
updates
*s so it points to just after the router it just read.
* *s so it points to just after the router it just read.
* mallocs a new router and returns it if all goes well, else returns
* NULL.
*/
...
...
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