Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
f4ff5a75
Commit
f4ff5a75
authored
20 years ago
by
Roger Dingledine
Browse files
Options
Downloads
Patches
Plain Diff
break circuit_build_needed_circs into its own func
svn:r1596
parent
c5052bec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/or/circuit.c
+37
-0
37 additions, 0 deletions
src/or/circuit.c
src/or/main.c
+7
-38
7 additions, 38 deletions
src/or/main.c
src/or/or.h
+1
-0
1 addition, 0 deletions
src/or/or.h
with
45 additions
and
38 deletions
src/or/circuit.c
+
37
−
0
View file @
f4ff5a75
...
...
@@ -514,6 +514,43 @@ int circuit_stream_is_being_handled(connection_t *conn) {
return
0
;
}
void
circuit_build_needed_circs
(
time_t
now
)
{
static
long
time_to_new_circuit
=
0
;
circuit_t
*
circ
;
if
(
options
.
SocksPort
)
/* launch a new circ for any pending streams that need one */
connection_ap_attach_pending
();
/* Build a new test circuit every 5 minutes */
#define TESTING_CIRCUIT_INTERVAL 300
circ
=
circuit_get_best
(
NULL
,
1
,
CIRCUIT_PURPOSE_C_GENERAL
);
if
(
time_to_new_circuit
<
now
)
{
client_dns_clean
();
circuit_expire_unused_circuits
();
circuit_reset_failure_count
();
if
(
circ
&&
circ
->
timestamp_dirty
)
{
log_fn
(
LOG_INFO
,
"Youngest circuit dirty; launching replacement."
);
/* make a new circuit */
circuit_launch_new
(
CIRCUIT_PURPOSE_C_GENERAL
,
NULL
);
}
else
if
(
options
.
RunTesting
&&
circ
&&
circ
->
timestamp_created
+
TESTING_CIRCUIT_INTERVAL
<
now
)
{
log_fn
(
LOG_INFO
,
"Creating a new testing circuit."
);
circuit_launch_new
(
CIRCUIT_PURPOSE_C_GENERAL
,
NULL
);
}
time_to_new_circuit
=
now
+
options
.
NewCircuitPeriod
;
time_to_new_circuit
=
now
+
options
.
NewCircuitPeriod
;
}
#define CIRCUIT_MIN_BUILDING 3
if
(
!
circ
&&
circuit_count_building
()
<
CIRCUIT_MIN_BUILDING
)
{
/* if there's no open circ, and less than 3 are on the way,
* go ahead and try another.
*/
circuit_launch_new
(
CIRCUIT_PURPOSE_C_GENERAL
,
NULL
);
}
}
/* update digest from the payload of cell. assign integrity part to cell. */
static
void
relay_set_digest
(
crypto_digest_env_t
*
digest
,
cell_t
*
cell
)
{
char
integrity
[
4
];
...
...
This diff is collapsed.
Click to expand it.
src/or/main.c
+
7
−
38
View file @
f4ff5a75
...
...
@@ -338,8 +338,6 @@ static void run_connection_housekeeping(int i, time_t now) {
*/
static
void
run_scheduled_events
(
time_t
now
)
{
static
long
time_to_fetch_directory
=
0
;
static
long
time_to_new_circuit
=
0
;
circuit_t
*
circ
;
int
i
;
/* 1. Every DirFetchPostPeriod seconds, we get a new directory and upload
...
...
@@ -388,49 +386,19 @@ static void run_scheduled_events(time_t now) {
* and we make a new circ if there are no clean circuits.
*/
if
(
has_fetched_directory
&&
(
options
.
SocksPort
||
options
.
RunTesting
))
{
if
(
options
.
SocksPort
)
/* launch a new circ for any pending streams that need one */
connection_ap_attach_pending
();
/* Build a new test circuit every 5 minutes */
#define TESTING_CIRCUIT_INTERVAL 300
circ
=
circuit_get_best
(
NULL
,
1
,
CIRCUIT_PURPOSE_C_GENERAL
);
if
(
time_to_new_circuit
<
now
)
{
client_dns_clean
();
circuit_expire_unused_circuits
();
circuit_reset_failure_count
();
if
(
circ
&&
circ
->
timestamp_dirty
)
{
log_fn
(
LOG_INFO
,
"Youngest circuit dirty; launching replacement."
);
/* make a new circuit */
circuit_launch_new
(
CIRCUIT_PURPOSE_C_GENERAL
,
NULL
);
}
else
if
(
options
.
RunTesting
&&
circ
&&
circ
->
timestamp_created
+
TESTING_CIRCUIT_INTERVAL
<
now
)
{
log_fn
(
LOG_INFO
,
"Creating a new testing circuit."
);
circuit_launch_new
(
CIRCUIT_PURPOSE_C_GENERAL
,
NULL
);
}
time_to_new_circuit
=
now
+
options
.
NewCircuitPeriod
;
}
#define CIRCUIT_MIN_BUILDING 3
if
(
!
circ
&&
circuit_count_building
()
<
CIRCUIT_MIN_BUILDING
)
{
/* if there's no open circ, and less than 3 are on the way,
* go ahead and try another.
*/
circuit_launch_new
(
CIRCUIT_PURPOSE_C_GENERAL
,
NULL
);
}
}
(
options
.
SocksPort
||
options
.
RunTesting
))
circuit_build_needed_circs
(
now
);
/*
5
. We do housekeeping for each connection... */
/*
4
. We do housekeeping for each connection... */
for
(
i
=
0
;
i
<
nfds
;
i
++
)
{
run_connection_housekeeping
(
i
,
now
);
}
/*
6
. And remove any marked circuits... */
/*
5
. And remove any marked circuits... */
circuit_close_all_marked
();
/* 7. and blow away any connections that need to die. can't do this later
#if 0
/* 6. and blow away any connections that need to die. can't do this later
* because we might open up a circuit and not realize we're about to cull
* the connection it's running over.
* XXX we can remove this step once we audit circuit-building to make sure
...
...
@@ -438,6 +406,7 @@ static void run_scheduled_events(time_t now) {
*/
for(i=0;i<nfds;i++)
conn_close_if_marked(i);
#endif
}
static
int
prepare_for_poll
(
void
)
{
...
...
This diff is collapsed.
Click to expand it.
src/or/or.h
+
1
−
0
View file @
f4ff5a75
...
...
@@ -716,6 +716,7 @@ circuit_t *circuit_get_rendezvous(const char *cookie);
void
circuit_expire_building
(
void
);
int
circuit_count_building
(
void
);
int
circuit_stream_is_being_handled
(
connection_t
*
conn
);
void
circuit_build_needed_circs
(
time_t
now
);
int
circuit_receive_relay_cell
(
cell_t
*
cell
,
circuit_t
*
circ
,
int
cell_direction
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment