summaryrefslogtreecommitdiff
path: root/src/feature/dirauth/shared_random_state.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-12-01 11:26:55 -0500
committerNick Mathewson <nickm@torproject.org>2018-12-01 11:26:55 -0500
commit51d94cea3370c0ddc7c18993f2a81eea11e51e36 (patch)
treedb3bb607e3083c23fd7e05807431cc292375eb8f /src/feature/dirauth/shared_random_state.c
parent7e9985b75aa69d4572aac739d44d50056ed20e82 (diff)
parent1a97379e5e5d349b4debd5ac61bedcca623dd386 (diff)
downloadtor-51d94cea3370c0ddc7c18993f2a81eea11e51e36.tar.gz
tor-51d94cea3370c0ddc7c18993f2a81eea11e51e36.zip
Merge branch 'maint-0.3.5'
Diffstat (limited to 'src/feature/dirauth/shared_random_state.c')
-rw-r--r--src/feature/dirauth/shared_random_state.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c
index 1ce06744d4..8c5b28b7cd 100644
--- a/src/feature/dirauth/shared_random_state.c
+++ b/src/feature/dirauth/shared_random_state.c
@@ -595,8 +595,10 @@ disk_state_update(void)
{
config_line_t **next, *line;
- tor_assert(sr_disk_state);
- tor_assert(sr_state);
+ if (BUG(!sr_disk_state))
+ return;
+ if (BUG(!sr_state))
+ return;
/* Reset current disk state. */
disk_state_reset();
@@ -760,7 +762,8 @@ disk_state_save_to_disk(void)
STATIC void
reset_state_for_new_protocol_run(time_t valid_after)
{
- tor_assert(sr_state);
+ if (BUG(!sr_state))
+ return;
/* Keep counters in track */
sr_state->n_reveal_rounds = 0;
@@ -1092,7 +1095,8 @@ sr_state_update(time_t valid_after)
{
sr_phase_t next_phase;
- tor_assert(sr_state);
+ if (BUG(!sr_state))
+ return;
/* Don't call this function twice in the same voting period. */
if (valid_after <= sr_state->valid_after) {
@@ -1131,7 +1135,8 @@ sr_state_update(time_t valid_after)
/* Count the current round */
if (sr_state->phase == SR_PHASE_COMMIT) {
/* invariant check: we've not entered reveal phase yet */
- tor_assert(sr_state->n_reveal_rounds == 0);
+ if (BUG(sr_state->n_reveal_rounds != 0))
+ return;
sr_state->n_commit_rounds++;
} else {
sr_state->n_reveal_rounds++;
@@ -1321,7 +1326,8 @@ sr_state_init(int save_to_disk, int read_from_disk)
void
set_sr_phase(sr_phase_t phase)
{
- tor_assert(sr_state);
+ if (BUG(!sr_state))
+ return;
sr_state->phase = phase;
}