summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-29 10:46:21 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-29 10:54:45 +0100
commit2798430e00f7e9186cd3d0f97c1e43897181006f (patch)
treee8815fcf8cc58e2ee1e38dc8a4caeee3fe2dc482 /src
parent62a3fc6d27d6c78ad2157cd1bf7884a922ea02d6 (diff)
downloadsystemd-2798430e00f7e9186cd3d0f97c1e43897181006f.tar.gz
systemd-2798430e00f7e9186cd3d0f97c1e43897181006f.tar.bz2
systemd-2798430e00f7e9186cd3d0f97c1e43897181006f.zip
machined: only Unref units that we AddRef'd
b92d0b4c5adef37e9de8f6cc22a0e27b97fcf3ad added AddRef to the StartTransientUnit call in machine_start_scope()/manager_start_scope() and a corresponding Unref call in machine_stop_scope(). But when we are running systemd-nspawn@ with --keep unit, the unit is not created by machined so the AddRef never happens. Then when trying to stop the unit, we'd get: systemd-machined[1101]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=UnrefUnit cookie=37 reply_cookie=0 signature=s error-name=n/a error-message=n/a systemd-machined[1101]: Got message type=error sender=:1.1 destination=:1.13 path=n/a interface=n/a member=n/a cookie=2443 reply_cookie=37 signature=s error-name=org.freedesktop.systemd1.NotReferenced error-message=Unit has not been referenced yet. systemd-machined[1101]: Failed to drop reference to machine scope, ignoring: Unit has not been referenced yet.
Diffstat (limited to 'src')
-rw-r--r--src/machine/machine.c10
-rw-r--r--src/machine/machine.h1
2 files changed, 8 insertions, 3 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c
index b5d017a671..c6475a5398 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -355,6 +355,7 @@ static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_er
return log_error_errno(r, "Failed to start machine scope: %s", bus_error_message(error, r));
m->unit = TAKE_PTR(scope);
+ m->referenced = true;
free_and_replace(m->scope_job, job);
}
@@ -422,9 +423,12 @@ static int machine_stop_scope(Machine *m) {
} else
free_and_replace(m->scope_job, job);
- q = manager_unref_unit(m->manager, m->unit, &error);
- if (q < 0)
- log_warning_errno(q, "Failed to drop reference to machine scope, ignoring: %s", bus_error_message(&error, r));
+ if (m->referenced) {
+ q = manager_unref_unit(m->manager, m->unit, &error);
+ if (q < 0)
+ log_warning_errno(q, "Failed to drop reference to machine scope, ignoring: %s", bus_error_message(&error, r));
+ m->referenced = false;
+ }
return r;
}
diff --git a/src/machine/machine.h b/src/machine/machine.h
index f7471be8f5..0a39e61052 100644
--- a/src/machine/machine.h
+++ b/src/machine/machine.h
@@ -54,6 +54,7 @@ struct Machine {
bool in_gc_queue:1;
bool started:1;
bool stopping:1;
+ bool referenced:1;
sd_bus_message *create_message;