int cgroup_attribute_apply(CGroupAttribute *a, CGroupBonding *b) {
int r;
- char *path = NULL;
- char *v = NULL;
+ _cleanup_free_ char *path = NULL, *v = NULL;
assert(a);
}
r = cg_get_path(a->controller, b->path, a->name, &path);
- if (r < 0) {
- free(v);
+ if (r < 0)
return r;
- }
r = write_one_line_file(path, v ? v : a->value);
if (r < 0)
log_warning("Failed to write '%s' to %s: %s", v ? v : a->value, path, strerror(-r));
- free(path);
- free(v);
-
return r;
}
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);