diff options
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/logind.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/login/logind.c b/src/login/logind.c index 8997b4689e..7fd6515ffd 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -782,12 +782,19 @@ finish: } int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **session) { + Session *s; char *p; assert(m); assert(cgroup); assert(session); + s = hashmap_get(m->cgroups, cgroup); + if (s) { + *session = s; + return 1; + } + p = strdup(cgroup); if (!p) { log_error("Out of memory."); @@ -795,24 +802,23 @@ int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **sess } for (;;) { - Session *s; char *e; - if (isempty(p) || streq(p, "/")) { + e = strrchr(p, '/'); + if (!e || e == p) { free(p); *session = NULL; return 0; } + *e = 0; + s = hashmap_get(m->cgroups, p); if (s) { free(p); *session = s; return 1; } - - assert_se(e = strrchr(p, '/')); - *e = 0; } } |