diff options
author | David Goulet <dgoulet@torproject.org> | 2018-04-17 09:31:50 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-04-23 10:57:28 -0400 |
commit | a4fcdc5decfe60bbd95aee2e5586e90c40b73225 (patch) | |
tree | 851d54d5947c7b9c91df5f0da7e063ceca641199 /src/or/periodic.c | |
parent | ed89bb32535fbf354b406a36f3176380a4e226bf (diff) | |
download | tor-a4fcdc5decfe60bbd95aee2e5586e90c40b73225.tar.gz tor-a4fcdc5decfe60bbd95aee2e5586e90c40b73225.zip |
main: Launch periodic events by roles
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/periodic.c')
-rw-r--r-- | src/or/periodic.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/or/periodic.c b/src/or/periodic.c index fa40965de1..42bea3ae65 100644 --- a/src/or/periodic.c +++ b/src/or/periodic.c @@ -78,7 +78,10 @@ periodic_event_dispatch(mainloop_event_t *ev, void *data) void periodic_event_reschedule(periodic_event_item_t *event) { - periodic_event_set_interval(event, 1); + /* Don't reschedule a disabled event. */ + if (periodic_event_is_enabled(event)) { + periodic_event_set_interval(event, 1); + } } /** Initializes the libevent backend for a periodic event. */ @@ -104,9 +107,15 @@ periodic_event_launch(periodic_event_item_t *event) log_err(LD_BUG, "periodic_event_launch without periodic_event_setup"); tor_assert(0); } + /* Event already enabled? This is a bug */ + if (periodic_event_is_enabled(event)) { + log_err(LD_BUG, "periodic_event_launch on an already enabled event"); + tor_assert(0); + } // Initial dispatch periodic_event_dispatch(event->ev, event); + event->enabled = 1; } /** Release all storage associated with <b>event</b> */ @@ -117,5 +126,6 @@ periodic_event_destroy(periodic_event_item_t *event) return; mainloop_event_free(event->ev); event->last_action_time = 0; + event->enabled = 0; } |