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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Hiro
Tor
Commits
a6864644
Commit
a6864644
authored
6 years ago
by
George Kadianakis
Committed by
Nick Mathewson
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Recreate voting schedule before use if it's outdated.
parent
2520ee34
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/or/voting_schedule.c
+25
-1
25 additions, 1 deletion
src/or/voting_schedule.c
src/or/voting_schedule.h
+4
-0
4 additions, 0 deletions
src/or/voting_schedule.h
with
29 additions
and
1 deletion
src/or/voting_schedule.c
+
25
−
1
View file @
a6864644
...
...
@@ -83,6 +83,10 @@ get_voting_schedule(const or_options_t *options, time_t now, int severity)
interval
=
(
int
)(
consensus
->
fresh_until
-
consensus
->
valid_after
);
vote_delay
=
consensus
->
vote_seconds
;
dist_delay
=
consensus
->
dist_seconds
;
/* Note down the consensus valid after, so that we detect outdated voting
* schedules in case of skewed clocks etc. */
new_voting_schedule
->
live_consensus_valid_after
=
consensus
->
valid_after
;
}
else
{
interval
=
options
->
TestingV3AuthInitialVotingInterval
;
vote_delay
=
options
->
TestingV3AuthInitialVoteDelay
;
...
...
@@ -138,14 +142,34 @@ voting_schedule_t voting_schedule;
time_t
voting_schedule_get_next_valid_after_time
(
void
)
{
time_t
now
=
approx_time
();
bool
need_to_recalculate_voting_schedule
=
false
;
/* This is a safe guard in order to make sure that the voting schedule
* static object is at least initialized. Using this function with a zeroed
* voting schedule can lead to bugs. */
if
(
tor_mem_is_zero
((
const
char
*
)
&
voting_schedule
,
sizeof
(
voting_schedule
)))
{
voting_schedule_recalculate_timing
(
get_options
(),
time
(
NULL
));
need_to_recalculate_voting_schedule
=
true
;
goto
done
;
/* no need for next check if we have to recalculate anyway */
}
/* Also make sure we are not using an outdated voting schedule. If we have a
* newer consensus, make sure we recalculate the voting schedule. */
const
networkstatus_t
*
ns
=
networkstatus_get_live_consensus
(
now
);
if
(
ns
&&
ns
->
valid_after
!=
voting_schedule
.
live_consensus_valid_after
)
{
log_info
(
LD_DIR
,
"Voting schedule is outdated: recalculating (%d/%d)"
,
(
int
)
ns
->
valid_after
,
(
int
)
voting_schedule
.
live_consensus_valid_after
);
need_to_recalculate_voting_schedule
=
true
;
}
done:
if
(
need_to_recalculate_voting_schedule
)
{
voting_schedule_recalculate_timing
(
get_options
(),
now
);
voting_schedule
.
created_on_demand
=
1
;
}
return
voting_schedule
.
interval_starts
;
}
...
...
This diff is collapsed.
Click to expand it.
src/or/voting_schedule.h
+
4
−
0
View file @
a6864644
...
...
@@ -43,6 +43,10 @@ typedef struct {
* timings only for the first vote even though this object was initilized
* prior to voting. */
int
created_on_demand
;
/** The valid-after time of the last live consensus that filled this voting
* schedule. It's used to detect outdated voting schedules. */
time_t
live_consensus_valid_after
;
}
voting_schedule_t
;
/* Public API. */
...
...
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