mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
cgroup: when getting cgroup empty notifications, always search up the tree
This commit is contained in:
parent
cd43ca73e1
commit
acb14d318b
7
TODO
7
TODO
@ -31,7 +31,7 @@ Features:
|
|||||||
|
|
||||||
* write RPM spec macros for presets
|
* write RPM spec macros for presets
|
||||||
|
|
||||||
* write man pages for systemd-cgtop, systemd-cat
|
* write man pages for systemd-cat
|
||||||
|
|
||||||
* journal: write man pages for API
|
* journal: write man pages for API
|
||||||
|
|
||||||
@ -73,8 +73,6 @@ Features:
|
|||||||
|
|
||||||
* move to LGPL2+
|
* move to LGPL2+
|
||||||
|
|
||||||
* logind: selinux is borked...
|
|
||||||
|
|
||||||
* logind: allow showing logout dialog from system
|
* logind: allow showing logout dialog from system
|
||||||
|
|
||||||
* document that %% can be used to write % in a string that is specifier extended
|
* document that %% can be used to write % in a string that is specifier extended
|
||||||
@ -164,8 +162,6 @@ Features:
|
|||||||
|
|
||||||
* GC unreferenced jobs (such as .device jobs)
|
* GC unreferenced jobs (such as .device jobs)
|
||||||
|
|
||||||
* cgroup_notify_empty(): recursively check groups up the tree, too
|
|
||||||
|
|
||||||
* when failing to start a service due to ratelimiting, try again later, if restart=always is set
|
* when failing to start a service due to ratelimiting, try again later, if restart=always is set
|
||||||
|
|
||||||
* write blog stories about:
|
* write blog stories about:
|
||||||
@ -175,6 +171,7 @@ Features:
|
|||||||
- remote access
|
- remote access
|
||||||
- how to pass throw-away units to systemd, or dynamically change properties of existing units
|
- how to pass throw-away units to systemd, or dynamically change properties of existing units
|
||||||
- how to integrate cgconfig and suchlike with systemd
|
- how to integrate cgconfig and suchlike with systemd
|
||||||
|
- resource control in systemd
|
||||||
|
|
||||||
* allow port=0 in .socket units
|
* allow port=0 in .socket units
|
||||||
|
|
||||||
|
46
src/cgroup.c
46
src/cgroup.c
@ -355,15 +355,55 @@ void manager_shutdown_cgroup(Manager *m, bool delete) {
|
|||||||
m->cgroup_hierarchy = NULL;
|
m->cgroup_hierarchy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding) {
|
||||||
|
CGroupBonding *b;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
assert(m);
|
||||||
|
assert(cgroup);
|
||||||
|
assert(bonding);
|
||||||
|
|
||||||
|
b = hashmap_get(m->cgroup_bondings, cgroup);
|
||||||
|
if (!b) {
|
||||||
|
*bonding = b;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strdup(cgroup);
|
||||||
|
if (!p)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
char *e;
|
||||||
|
|
||||||
|
e = strrchr(p, '/');
|
||||||
|
if (!e || e == p) {
|
||||||
|
free(p);
|
||||||
|
*bonding = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*e = 0;
|
||||||
|
|
||||||
|
b = hashmap_get(m->cgroup_bondings, p);
|
||||||
|
if (b) {
|
||||||
|
free(p);
|
||||||
|
*bonding = b;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int cgroup_notify_empty(Manager *m, const char *group) {
|
int cgroup_notify_empty(Manager *m, const char *group) {
|
||||||
CGroupBonding *l, *b;
|
CGroupBonding *l, *b;
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
assert(group);
|
assert(group);
|
||||||
|
|
||||||
l = hashmap_get(m->cgroup_bondings, group);
|
r = cgroup_bonding_get(m, group, &l);
|
||||||
if (!l)
|
if (r <= 0)
|
||||||
return 0;
|
return r;
|
||||||
|
|
||||||
LIST_FOREACH(by_path, b, l) {
|
LIST_FOREACH(by_path, b, l) {
|
||||||
int t;
|
int t;
|
||||||
|
@ -86,6 +86,7 @@ pid_t cgroup_bonding_search_main_pid_list(CGroupBonding *b);
|
|||||||
int manager_setup_cgroup(Manager *m);
|
int manager_setup_cgroup(Manager *m);
|
||||||
void manager_shutdown_cgroup(Manager *m, bool delete);
|
void manager_shutdown_cgroup(Manager *m, bool delete);
|
||||||
|
|
||||||
|
int cgroup_bonding_get(Manager *m, const char *cgroup, CGroupBonding **bonding);
|
||||||
int cgroup_notify_empty(Manager *m, const char *group);
|
int cgroup_notify_empty(Manager *m, const char *group);
|
||||||
|
|
||||||
Unit* cgroup_unit_by_pid(Manager *m, pid_t pid);
|
Unit* cgroup_unit_by_pid(Manager *m, pid_t pid);
|
||||||
|
@ -782,12 +782,19 @@ finish:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **session) {
|
int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **session) {
|
||||||
|
Session *s;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
assert(cgroup);
|
assert(cgroup);
|
||||||
assert(session);
|
assert(session);
|
||||||
|
|
||||||
|
s = hashmap_get(m->cgroups, cgroup);
|
||||||
|
if (s) {
|
||||||
|
*session = s;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
p = strdup(cgroup);
|
p = strdup(cgroup);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
log_error("Out of memory.");
|
log_error("Out of memory.");
|
||||||
@ -795,24 +802,23 @@ int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Session *s;
|
|
||||||
char *e;
|
char *e;
|
||||||
|
|
||||||
if (isempty(p) || streq(p, "/")) {
|
e = strrchr(p, '/');
|
||||||
|
if (!e || e == p) {
|
||||||
free(p);
|
free(p);
|
||||||
*session = NULL;
|
*session = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*e = 0;
|
||||||
|
|
||||||
s = hashmap_get(m->cgroups, p);
|
s = hashmap_get(m->cgroups, p);
|
||||||
if (s) {
|
if (s) {
|
||||||
free(p);
|
free(p);
|
||||||
*session = s;
|
*session = s;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_se(e = strrchr(p, '/'));
|
|
||||||
*e = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user