diff options
author | Vladimir Kobal <vlad@prokk.net> | 2019-03-12 16:35:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-12 16:35:24 +0200 |
commit | db74925edb6e1867c071adfafe8d196cfc7f6d18 (patch) | |
tree | 44dc0986a710698120e6b1f27c278d1965609148 | |
parent | d6d7cb59fe118902bbc853ba4a6b0ce7b547f64b (diff) |
Fix a bug in cgroups renaming (#5612)
-rw-r--r-- | collectors/cgroups.plugin/sys_fs_cgroup.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c index 5d3f14f5ed..80b3960b9c 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.c +++ b/collectors/cgroups.plugin/sys_fs_cgroup.c @@ -888,7 +888,7 @@ static inline void cgroup_get_chart_name(struct cgroup *cg) { pid_t cgroup_pid; char command[CGROUP_CHARTID_LINE_MAX + 1]; - snprintfz(command, CGROUP_CHARTID_LINE_MAX, "exec %s '%s'", cgroups_rename_script, cg->id); + snprintfz(command, CGROUP_CHARTID_LINE_MAX, "exec %s '%s'", cgroups_rename_script, cg->chart_id); debug(D_CGROUP, "executing command \"%s\" for cgroup '%s'", command, cg->id); FILE *fp = mypopen(command, &cgroup_pid); @@ -908,12 +908,14 @@ static inline void cgroup_get_chart_name(struct cgroup *cg) { if(likely(!name_error)) cg->pending_renames = 0; - freez(cg->chart_title); - cg->chart_title = cgroup_title_strdupz(s); + if(likely(cg->pending_renames < 2)) { + freez(cg->chart_title); + cg->chart_title = cgroup_title_strdupz(s); - freez(cg->chart_id); - cg->chart_id = cgroup_chart_id_strdupz(s); - cg->hash_chart = simple_hash(cg->chart_id); + freez(cg->chart_id); + cg->chart_id = cgroup_chart_id_strdupz(s); + cg->hash_chart = simple_hash(cg->chart_id); + } } } } |