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) {
|
int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
|
||||||
_cleanup_free_ char *unit = NULL;
|
|
||||||
Machine *mm;
|
Machine *mm;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -1485,12 +1484,14 @@ int manager_get_machine_by_pid(Manager *m, pid_t pid, Machine **machine) {
|
|||||||
assert(pid >= 1);
|
assert(pid >= 1);
|
||||||
assert(machine);
|
assert(machine);
|
||||||
|
|
||||||
r = cg_pid_get_unit(pid, &unit);
|
mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid));
|
||||||
if (r < 0)
|
if (!mm) {
|
||||||
mm = hashmap_get(m->machine_leaders, UINT_TO_PTR(pid));
|
_cleanup_free_ char *unit = NULL;
|
||||||
else
|
|
||||||
mm = hashmap_get(m->machine_units, unit);
|
|
||||||
|
|
||||||
|
r = cg_pid_get_unit(pid, &unit);
|
||||||
|
if (r >= 0)
|
||||||
|
mm = hashmap_get(m->machine_units, unit);
|
||||||
|
}
|
||||||
if (!mm)
|
if (!mm)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user