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/scope.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/scope.c')
-rw-r--r-- | src/core/scope.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/scope.c b/src/core/scope.c index a247da206f..af6311bb5f 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -48,7 +48,7 @@ static void scope_done(Unit *u) { s->controller = mfree(s->controller); s->controller_track = sd_bus_track_unref(s->controller_track); - s->timer_event_source = sd_event_source_unref(s->timer_event_source); + s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source); } static int scope_arm_timer(Scope *s, usec_t usec) { @@ -92,7 +92,7 @@ static void scope_set_state(Scope *s, ScopeState state) { s->state = state; if (!IN_SET(state, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL)) - s->timer_event_source = sd_event_source_unref(s->timer_event_source); + s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source); if (IN_SET(state, SCOPE_DEAD, SCOPE_FAILED)) { unit_unwatch_all_pids(UNIT(s)); |