diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-02-03 05:25:31 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-02-03 05:25:31 +0100 |
commit | acb14d318b84bda00d1e666d7dab6794d5bbeb3f (patch) | |
tree | bb30240c680d5a92ca61189ba8b0a8ebf2672004 /src/login | |
parent | cd43ca73e19511f999c80995937e418c35c30ee8 (diff) |
cgroup: when getting cgroup empty notifications, always search up the tree
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; } } |