diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-10 10:22:07 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-05-12 12:08:52 +0200 |
commit | 5dcadb4c8320f6a7b8a9353404874d43668e4648 (patch) | |
tree | 2039780ceecdcd107951df33b980089ba42d0704 /src/core/timer.c | |
parent | 8808d3289e6a595828ef38b05c0f2c7706be1dae (diff) | |
download | systemd-5dcadb4c8320f6a7b8a9353404874d43668e4648.tar.gz |
core: disable event sources before unreffing them
This mirrors the change done for systemd-resolved in
97935302283729c9206b84f5e00b1aff0f78ad19. Quoting that patch:
> We generally operate on the assumption that a source is "gone" as soon as we
> unref it. This is generally true because we have the only reference. But if
> something else holds the reference, our unref doesn't really stop the source
> and it could fire again.
In particular, we take temporary references from sd-event code, and when called
from an sd-event callback, we could temporarily see this elevated reference
count. This patch doesn't seem to change anything, but I think it's nicer to do
the same change as in other places and not rely on _unref() immediately
disabling the source.
Diffstat (limited to 'src/core/timer.c')
-rw-r--r-- | src/core/timer.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/timer.c b/src/core/timer.c index b0caaf3850..e064ad9a2d 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -65,8 +65,8 @@ static void timer_done(Unit *u) { timer_free_values(t); - t->monotonic_event_source = sd_event_source_unref(t->monotonic_event_source); - t->realtime_event_source = sd_event_source_unref(t->realtime_event_source); + t->monotonic_event_source = sd_event_source_disable_unref(t->monotonic_event_source); + t->realtime_event_source = sd_event_source_disable_unref(t->realtime_event_source); free(t->stamp_path); } @@ -296,8 +296,8 @@ static void timer_set_state(Timer *t, TimerState state) { t->state = state; if (state != TIMER_WAITING) { - t->monotonic_event_source = sd_event_source_unref(t->monotonic_event_source); - t->realtime_event_source = sd_event_source_unref(t->realtime_event_source); + t->monotonic_event_source = sd_event_source_disable_unref(t->monotonic_event_source); + t->realtime_event_source = sd_event_source_disable_unref(t->realtime_event_source); t->next_elapse_monotonic_or_boottime = USEC_INFINITY; t->next_elapse_realtime = USEC_INFINITY; } |