aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirvote.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-10-27 09:16:29 -0400
committerDavid Goulet <dgoulet@torproject.org>2017-10-27 09:23:37 -0400
commit7ee0a2b9aa71693a09687dca431cc1880774f4f4 (patch)
treecd6bb633dfcf0f7731671af751cf3b2044ed2123 /src/or/dirvote.c
parent60164f057c4ac5471754f0326ab631448cd7c120 (diff)
downloadtor-7ee0a2b9aa71693a09687dca431cc1880774f4f4.tar.gz
tor-7ee0a2b9aa71693a09687dca431cc1880774f4f4.zip
sr: Don't use a dynamic voting schedule
The exposed get_voting_schedule() allocates and return a new object everytime it is called leading to an awful lot of memory allocation when getting the start time of the current round which is done for each node in the consensus. Closes #23623 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r--src/or/dirvote.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index ddaadb3871..6f237e9b26 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2790,7 +2790,7 @@ dirvote_get_start_of_next_interval(time_t now, int interval, int offset)
/* Populate and return a new voting_schedule_t that can be used to schedule
* voting. The object is allocated on the heap and it's the responsibility of
* the caller to free it. Can't fail. */
-voting_schedule_t *
+static voting_schedule_t *
get_voting_schedule(const or_options_t *options, time_t now, int severity)
{
int interval, vote_delay, dist_delay;
@@ -2845,7 +2845,7 @@ get_voting_schedule(const or_options_t *options, time_t now, int severity)
/** Frees a voting_schedule_t. This should be used instead of the generic
* tor_free. */
-void
+static void
voting_schedule_free(voting_schedule_t *voting_schedule_to_free)
{
if (!voting_schedule_to_free)
@@ -2857,18 +2857,9 @@ static voting_schedule_t voting_schedule;
/* Using the time <b>now</b>, return the next voting valid-after time. */
time_t
-get_next_valid_after_time(time_t now)
+dirvote_get_next_valid_after_time(void)
{
- time_t next_valid_after_time;
- const or_options_t *options = get_options();
- voting_schedule_t *new_voting_schedule =
- get_voting_schedule(options, now, LOG_INFO);
- tor_assert(new_voting_schedule);
-
- next_valid_after_time = new_voting_schedule->interval_starts;
- voting_schedule_free(new_voting_schedule);
-
- return next_valid_after_time;
+ return voting_schedule.interval_starts;
}
/** Set voting_schedule to hold the timing for the next vote we should be