]> git.ipfire.org Git - thirdparty/systemd.git/commit
machined: simplify reference handling for units
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 Nov 2019 13:41:32 +0000 (14:41 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 22 Nov 2019 09:24:32 +0000 (10:24 +0100)
commiteec12b7756e2cada16e3b8a9c02f9eaf62df5409
tree6c8c1ebc656435a12714a8072ad8185f59038beb
parenta01ecfa982e0e72f1ab52dade7bafe644bda893e
machined: simplify reference handling for units

Before, we'd unref from machine_stop_unit, still keeping the unit name around,
and only forget the name later, when garbage collecting. If we didn't call
manager_stop_unit(), then we wouldn't do the unref. Let's unref at the same
point where we do garbage collection, so that it is always true that
iff we have the name generated with AddRef=1, then have a reference to the unit,
and as soon as we forget the name, we drop the reference.

This should fix the issue when repeated systemd-nspawn --register=yes fails
with "scope already exists" error.

Incidentally, this fixes an error in the code path where r was used instead of q.
src/machine/machine.c