mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 11:27:32 +03:00
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.
This commit is contained in:
parent
c454426c54
commit
077c8c366b
@ -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);
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user