The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3268
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From c3f5890cfee19b265c278c26e5d5b1fc7137352a Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Tue, 25 Feb 2020 13:36:51 +0100 Subject: [PATCH] cgroups: remove unused method and cleanup cgroup_exit() Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- src/lxc/cgroups/cgfsng.c | 52 ---------------------------------------- src/lxc/cgroups/cgroup.c | 13 ++++------ src/lxc/cgroups/cgroup.h | 1 - 3 files changed, 4 insertions(+), 62 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 3e5345b62d..aa054a63d3 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -1833,57 +1833,6 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops, return retval; } -static int recursive_count_nrtasks(char *dirname) -{ - __do_free char *path = NULL; - __do_closedir DIR *dir = NULL; - struct dirent *direntp; - int count = 0, ret; - - dir = opendir(dirname); - if (!dir) - return 0; - - while ((direntp = readdir(dir))) { - struct stat mystat; - - if (!strcmp(direntp->d_name, ".") || - !strcmp(direntp->d_name, "..")) - continue; - - path = must_make_path(dirname, direntp->d_name, NULL); - - if (lstat(path, &mystat)) - continue; - - if (!S_ISDIR(mystat.st_mode)) - continue; - - count += recursive_count_nrtasks(path); - } - - path = must_make_path(dirname, "cgroup.procs", NULL); - ret = lxc_count_file_lines(path); - if (ret != -1) - count += ret; - - return count; -} - -__cgfsng_ops static int cgfsng_nrtasks(struct cgroup_ops *ops) -{ - __do_free char *path = NULL; - - if (!ops) - return ret_set_errno(-1, ENOENT); - - if (!ops->container_cgroup || !ops->hierarchies) - return ret_set_errno(-1, EINVAL); - - path = must_make_path(ops->hierarchies[0]->container_full_path, NULL); - return recursive_count_nrtasks(path); -} - /* Only root needs to escape to the cgroup of its init. */ __cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops, struct lxc_conf *conf) @@ -3279,7 +3228,6 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf) cgfsng_ops->attach = cgfsng_attach; cgfsng_ops->chown = cgfsng_chown; cgfsng_ops->mount = cgfsng_mount; - cgfsng_ops->nrtasks = cgfsng_nrtasks; cgfsng_ops->devices_activate = cgfsng_devices_activate; return move_ptr(cgfsng_ops); diff --git a/src/lxc/cgroups/cgroup.c b/src/lxc/cgroups/cgroup.c index 2e9670e3b1..37fd0e377d 100644 --- a/src/lxc/cgroups/cgroup.c +++ b/src/lxc/cgroups/cgroup.c @@ -53,13 +53,10 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf) void cgroup_exit(struct cgroup_ops *ops) { - char **cur; - struct hierarchy **it; - if (!ops) return; - for (cur = ops->cgroup_use; cur && *cur; cur++) + for (char **cur = ops->cgroup_use; cur && *cur; cur++) free(*cur); free(ops->cgroup_pattern); @@ -69,14 +66,12 @@ void cgroup_exit(struct cgroup_ops *ops) if (ops->cgroup2_devices) bpf_program_free(ops->cgroup2_devices); - for (it = ops->hierarchies; it && *it; it++) { - char **p; - - for (p = (*it)->controllers; p && *p; p++) + for (struct hierarchy **it = ops->hierarchies; it && *it; it++) { + for (char **p = (*it)->controllers; p && *p; p++) free(*p); free((*it)->controllers); - for (p = (*it)->cgroup2_chown; p && *p; p++) + for (char **p = (*it)->cgroup2_chown; p && *p; p++) free(*p); free((*it)->cgroup2_chown); diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h index 46644c8445..32692fd711 100644 --- a/src/lxc/cgroups/cgroup.h +++ b/src/lxc/cgroups/cgroup.h @@ -161,7 +161,6 @@ struct cgroup_ops { const char *lxcpath, pid_t pid); bool (*mount)(struct cgroup_ops *ops, struct lxc_handler *handler, const char *root, int type); - int (*nrtasks)(struct cgroup_ops *ops); bool (*devices_activate)(struct cgroup_ops *ops, struct lxc_handler *handler); bool (*monitor_delegate_controllers)(struct cgroup_ops *ops);
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel