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>
Mon, 12 Jul 2021 11:30:54 +0000 (13:30 +0200)
commit67782e10f0dd0f2feeb036aa4380fa5c6c55aaea
treee743789567670907b1afe4f372e69775599f6189
parentbeedc8b4b79f3bbde8efeaa748ca09ea0d7bf4bd
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.

(cherry picked from commit 5dcadb4c8320f6a7b8a9353404874d43668e4648)
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