summaryrefslogtreecommitdiff
path: root/src/core/cgroup-attr.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-01-12 04:24:12 +0100
committerLennart Poettering <lennart@poettering.net>2013-01-14 21:24:57 +0100
commit246aa6dd9dcea84bb945d16ec86e69f869dbb9b4 (patch)
tree375b4ff2acb7f18461a7f1c44167575fa58e8a97 /src/core/cgroup-attr.c
parent748ebafa7a10d4e1f168dd8ae0193124cdf4226e (diff)
core: add bus API and systemctl commands for altering cgroup parameters during runtime
Diffstat (limited to 'src/core/cgroup-attr.c')
-rw-r--r--src/core/cgroup-attr.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/core/cgroup-attr.c b/src/core/cgroup-attr.c
index 71af09cf87..cedf37de50 100644
--- a/src/core/cgroup-attr.c
+++ b/src/core/cgroup-attr.c
@@ -71,23 +71,42 @@ int cgroup_attribute_apply_list(CGroupAttribute *first, CGroupBonding *b) {
return r;
}
-CGroupAttribute *cgroup_attribute_find_list(CGroupAttribute *first, const char *controller, const char *name) {
+CGroupAttribute *cgroup_attribute_find_list(
+ CGroupAttribute *first,
+ const char *controller,
+ const char *name) {
CGroupAttribute *a;
- assert(controller);
assert(name);
- LIST_FOREACH(by_unit, a, first)
- if (streq(a->controller, controller) &&
- streq(a->name, name))
- return a;
+ LIST_FOREACH(by_unit, a, first) {
+
+
+ if (controller) {
+ if (streq(a->controller, controller) && streq(a->name, name))
+ return a;
+
+ } else if (streq(a->name, name)) {
+ size_t x, y;
+ x = strlen(a->controller);
+ y = strlen(name);
+
+ if (y > x &&
+ memcmp(a->controller, name, x) == 0 &&
+ name[x] == '.')
+ return a;
+ }
+ }
return NULL;
}
-static void cgroup_attribute_free(CGroupAttribute *a) {
+void cgroup_attribute_free(CGroupAttribute *a) {
assert(a);
+ if (a->unit)
+ LIST_REMOVE(CGroupAttribute, by_unit, a->unit->cgroup_attributes, a);
+
free(a->controller);
free(a->name);
free(a->value);