mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
logind: use manager_get_session_by_leader in manager_get_session_by_pidref
This commit is contained in:
@@ -368,7 +368,7 @@ int manager_process_button_device(Manager *m, sd_device *d) {
|
||||
|
||||
int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret) {
|
||||
_cleanup_free_ char *unit = NULL;
|
||||
Session *s;
|
||||
Session *s = NULL;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
@@ -376,16 +376,13 @@ int manager_get_session_by_pidref(Manager *m, const PidRef *pid, Session **ret)
|
||||
if (!pidref_is_set(pid))
|
||||
return -EINVAL;
|
||||
|
||||
s = hashmap_get(m->sessions_by_leader, pid);
|
||||
if (s) {
|
||||
r = pidref_verify(pid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
r = cg_pidref_get_unit(pid, &unit);
|
||||
if (r >= 0)
|
||||
s = hashmap_get(m->session_units, unit);
|
||||
}
|
||||
r = manager_get_session_by_leader(m, pid, ret);
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = cg_pidref_get_unit(pid, &unit);
|
||||
if (r >= 0)
|
||||
s = hashmap_get(m->session_units, unit);
|
||||
|
||||
if (ret)
|
||||
*ret = s;
|
||||
|
||||
Reference in New Issue
Block a user