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
184f4e60
Commit
184f4e60
authored
20 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Rotate dnsworkers and cpuworkers on SIGHUP, so they get new config settings too
svn:r1950
parent
0d1b4b50
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/or/dns.c
+25
-3
25 additions, 3 deletions
src/or/dns.c
src/or/main.c
+5
-0
5 additions, 0 deletions
src/or/main.c
with
30 additions
and
3 deletions
src/or/dns.c
+
25
−
3
View file @
184f4e60
...
@@ -35,9 +35,11 @@ extern or_options_t options; /* command-line and config-file options */
...
@@ -35,9 +35,11 @@ extern or_options_t options; /* command-line and config-file options */
#define DNS_RESOLVE_SUCCEEDED 3
#define DNS_RESOLVE_SUCCEEDED 3
/** How many dnsworkers we have running right now. */
/** How many dnsworkers we have running right now. */
int
num_dnsworkers
=
0
;
static
int
num_dnsworkers
=
0
;
/** How many of the running dnsworkers have an assigned task right now. */
/** How many of the running dnsworkers have an assigned task right now. */
int
num_dnsworkers_busy
=
0
;
static
int
num_dnsworkers_busy
=
0
;
/** When did we last rotate the dnsworkers? */
static
time_t
last_rotation_time
=
0
;
/** Linked list of connections waiting for a DNS answer. */
/** Linked list of connections waiting for a DNS answer. */
struct
pending_connection_t
{
struct
pending_connection_t
{
...
@@ -92,6 +94,7 @@ static void init_cache_tree(void) {
...
@@ -92,6 +94,7 @@ static void init_cache_tree(void) {
/** Initialize the DNS subsystem; called by the OR process. */
/** Initialize the DNS subsystem; called by the OR process. */
void
dns_init
(
void
)
{
void
dns_init
(
void
)
{
init_cache_tree
();
init_cache_tree
();
last_rotation_time
=
time
(
NULL
);
spawn_enough_dnsworkers
();
spawn_enough_dnsworkers
();
}
}
...
@@ -535,10 +538,29 @@ int connection_dns_process_inbuf(connection_t *conn) {
...
@@ -535,10 +538,29 @@ int connection_dns_process_inbuf(connection_t *conn) {
conn
->
address
=
tor_strdup
(
"<idle>"
);
conn
->
address
=
tor_strdup
(
"<idle>"
);
conn
->
state
=
DNSWORKER_STATE_IDLE
;
conn
->
state
=
DNSWORKER_STATE_IDLE
;
num_dnsworkers_busy
--
;
num_dnsworkers_busy
--
;
if
(
conn
->
timestamp_created
<
last_rotation_time
)
{
connection_mark_for_close
(
conn
);
num_dnsworkers
--
;
spawn_enough_dnsworkers
();
}
return
0
;
return
0
;
}
}
/** Close and re-open all idle dnsworkers; schedule busy ones to be closed
* and re-opened once they're no longer busy.
**/
void
dnsworkers_rotate
(
void
)
{
connection_t
*
dnsconn
;
while
((
dnsconn
=
connection_get_by_type_state
(
CONN_TYPE_DNSWORKER
,
DNSWORKER_STATE_IDLE
)))
{
connection_mark_for_close
(
dnsconn
);
num_dnsworkers
--
;
}
last_rotation_time
=
time
(
NULL
);
spawn_enough_dnsworkers
();
}
/** Implementation for DNS workers; this code runs in a separate
/** Implementation for DNS workers; this code runs in a separate
* execution context. It takes as its argument an fdarray as returned
* execution context. It takes as its argument an fdarray as returned
* by socketpair(), and communicates via fdarray[1]. The protocol is
* by socketpair(), and communicates via fdarray[1]. The protocol is
...
...
This diff is collapsed.
Click to expand it.
src/or/main.c
+
5
−
0
View file @
184f4e60
...
@@ -638,6 +638,11 @@ static int do_hup(void) {
...
@@ -638,6 +638,11 @@ static int do_hup(void) {
directory_get_from_dirserver
(
DIR_PURPOSE_FETCH_DIR
,
NULL
,
0
);
directory_get_from_dirserver
(
DIR_PURPOSE_FETCH_DIR
,
NULL
,
0
);
}
}
if
(
options
.
ORPort
)
{
if
(
options
.
ORPort
)
{
/* Restart cpuworker and dnsworker processes, so they get up-to-date
* configuration options. */
cpuworkers_rotate
();
dnsworkers_rotate
();
/* Rebuild fresh descriptor as needed. */
router_rebuild_descriptor
();
router_rebuild_descriptor
();
sprintf
(
keydir
,
"%s/router.desc"
,
options
.
DataDirectory
);
sprintf
(
keydir
,
"%s/router.desc"
,
options
.
DataDirectory
);
log_fn
(
LOG_INFO
,
"Dumping descriptor to %s..."
,
keydir
);
log_fn
(
LOG_INFO
,
"Dumping descriptor to %s..."
,
keydir
);
...
...
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