]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/scope.c
core: disable event sources before unreffing them
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 May 2021 08:22:07 +0000 (10:22 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 12 May 2021 10:08:52 +0000 (12:08 +0200)
commit5dcadb4c8320f6a7b8a9353404874d43668e4648
tree2039780ceecdcd107951df33b980089ba42d0704
parent8808d3289e6a595828ef38b05c0f2c7706be1dae
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.
13 files changed:
src/core/automount.c
src/core/cgroup.c
src/core/dbus.c
src/core/job.c
src/core/manager.c
src/core/mount.c
src/core/path.c
src/core/scope.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/timer.c
src/core/unit.c