summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/login/logind-dbus.c38
-rw-r--r--src/login/logind.c12
-rw-r--r--src/machine/machined-dbus.c22
-rw-r--r--src/machine/machined.c12
4 files changed, 83 insertions, 1 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index a52f020b34..eeff84394e 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2411,6 +2411,44 @@ DBusHandlerResult bus_message_filter(
if (u)
user_add_to_gc_queue(u);
}
+ } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Manager", "UnitRemoved")) {
+
+ const char *path, *unit;
+ Session *session;
+ User *user;
+
+ if (!dbus_message_get_args(message, &error,
+ DBUS_TYPE_STRING, &unit,
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID)) {
+ log_error("Failed to parse UnitRemoved message: %s", bus_error_message(&error));
+ goto finish;
+ }
+
+ session = hashmap_get(m->session_units, unit);
+ if (session) {
+ hashmap_remove(m->session_units, session->scope);
+ free(session->scope);
+ session->scope = NULL;
+
+ session_add_to_gc_queue(session);
+ }
+
+ user = hashmap_get(m->user_units, unit);
+ if (user) {
+
+ if (streq_ptr(unit, user->service)) {
+ hashmap_remove(m->user_units, user->service);
+ free(user->service);
+ user->service = NULL;
+ } else if (streq_ptr(unit, user->slice)) {
+ hashmap_remove(m->user_units, user->slice);
+ free(user->slice);
+ user->slice = NULL;
+ }
+
+ user_add_to_gc_queue(user);
+ }
}
finish:
diff --git a/src/login/logind.c b/src/login/logind.c
index e37a1071a2..fcb3ccf4a5 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -1023,6 +1023,18 @@ static int manager_connect_bus(Manager *m) {
dbus_bus_add_match(m->bus,
"type='signal',"
"sender='org.freedesktop.systemd1',"
+ "interface='org.freedesktop.systemd1.Manager',"
+ "member='UnitRemoved',"
+ "path='/org/freedesktop/systemd1'",
+ &error);
+ if (dbus_error_is_set(&error)) {
+ log_error("Failed to add match for UnitRemoved: %s", bus_error_message(&error));
+ dbus_error_free(&error);
+ }
+
+ dbus_bus_add_match(m->bus,
+ "type='signal',"
+ "sender='org.freedesktop.systemd1',"
"interface='org.freedesktop.DBus.Properties',"
"member='PropertiesChanged'",
&error);
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index a81f37c5ca..1b1eb3a333 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -531,7 +531,6 @@ DBusHandlerResult bus_message_filter(
goto finish;
}
-
mm = hashmap_get(m->machine_units, unit);
if (mm) {
if (streq_ptr(path, mm->scope_job)) {
@@ -570,6 +569,27 @@ DBusHandlerResult bus_message_filter(
if (mm)
machine_add_to_gc_queue(mm);
}
+
+ } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Manager", "UnitRemoved")) {
+ const char *path, *unit;
+ Machine *mm;
+
+ if (!dbus_message_get_args(message, &error,
+ DBUS_TYPE_STRING, &unit,
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID)) {
+ log_error("Failed to parse UnitRemoved message: %s", bus_error_message(&error));
+ goto finish;
+ }
+
+ mm = hashmap_get(m->machine_units, unit);
+ if (mm) {
+ hashmap_remove(m->machine_units, mm->scope);
+ free(mm->scope);
+ mm->scope = NULL;
+
+ machine_add_to_gc_queue(mm);
+ }
}
finish:
diff --git a/src/machine/machined.c b/src/machine/machined.c
index 86f8de9195..f2803a18c9 100644
--- a/src/machine/machined.c
+++ b/src/machine/machined.c
@@ -213,6 +213,18 @@ static int manager_connect_bus(Manager *m) {
dbus_bus_add_match(m->bus,
"type='signal',"
"sender='org.freedesktop.systemd1',"
+ "interface='org.freedesktop.systemd1.Manager',"
+ "member='UnitRemoved',"
+ "path='/org/freedesktop/systemd1'",
+ &error);
+ if (dbus_error_is_set(&error)) {
+ log_error("Failed to add match for UnitRemoved: %s", bus_error_message(&error));
+ dbus_error_free(&error);
+ }
+
+ dbus_bus_add_match(m->bus,
+ "type='signal',"
+ "sender='org.freedesktop.systemd1',"
"interface='org.freedesktop.DBus.Properties',"
"member='PropertiesChanged'",
&error);