Ensure channel closed if an error occurs in cgroup input (#4606)

This commit is contained in:
Daniel Nelson 2018-08-29 11:38:40 -07:00 committed by GitHub
parent 3adcc3a93d
commit 1e3edbc55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -81,6 +81,7 @@ func isDir(path string) (bool, error) {
}
func (g *CGroup) generateDirs(list chan<- pathInfo) {
defer close(list)
for _, dir := range g.Paths {
// getting all dirs that match the pattern 'dir'
items, err := filepath.Glob(dir)
@ -101,10 +102,10 @@ func (g *CGroup) generateDirs(list chan<- pathInfo) {
}
}
}
close(list)
}
func (g *CGroup) generateFiles(dir string, list chan<- pathInfo) {
defer close(list)
for _, file := range g.Files {
// getting all file paths that match the pattern 'dir + file'
// path.Base make sure that file variable does not contains part of path
@ -126,7 +127,6 @@ func (g *CGroup) generateFiles(dir string, list chan<- pathInfo) {
}
}
}
close(list)
}
// ======================================================================