summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-23 14:04:31 +0200
committerLennart Poettering <lennart@poettering.net>2015-08-24 22:46:45 +0200
commit077c8c366b58222629ed953abf2faa74ebadb769 (patch)
tree532b3ee16c3889bcd5ea18591ac4e4ca6d0681c8 /src
parentc454426c54c9beb274f415a80c64a4f1580700e7 (diff)
machined: always look for leader PID first
When looking for the machine belonging to a PID, always look for the leader first, only then fall back to a cgroup check. We keep direct track of the leader PID, but only indirectly of the cgroup, hence prefer the PID.
Diffstat (limited to 'src')
-rw-r--r--src/machine/machined-dbus.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index da3ab26e89..93514986f3 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -1477,7 +1477,6 @@ int manager_job_is_active(Manager *manager, const char *path) {
}
int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
- _cleanup_free_ char *unit = NULL;
Machine *mm;
int r;
@@ -1485,12 +1484,14 @@ int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
assert(pid >= 1);
assert(machine);
- r = cg_pid_get_unit(pid, &unit);
- if (r < 0)
- mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid));
- else
- mm = hashmap_get(m->machine_units, unit);
+ mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid));
+ if (!mm) {
+ _cleanup_free_ char *unit = NULL;
+ r = cg_pid_get_unit(pid, &unit);
+ if (r >= 0)
+ mm = hashmap_get(m->machine_units, unit);
+ }
if (!mm)
return 0;