Ensure channel closed if an error occurs in cgroup input (#4606)
This commit is contained in:
parent
3adcc3a93d
commit
1e3edbc55d
|
@ -81,6 +81,7 @@ func isDir(path string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *CGroup) generateDirs(list chan<- pathInfo) {
|
func (g *CGroup) generateDirs(list chan<- pathInfo) {
|
||||||
|
defer close(list)
|
||||||
for _, dir := range g.Paths {
|
for _, dir := range g.Paths {
|
||||||
// getting all dirs that match the pattern 'dir'
|
// getting all dirs that match the pattern 'dir'
|
||||||
items, err := filepath.Glob(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) {
|
func (g *CGroup) generateFiles(dir string, list chan<- pathInfo) {
|
||||||
|
defer close(list)
|
||||||
for _, file := range g.Files {
|
for _, file := range g.Files {
|
||||||
// getting all file paths that match the pattern 'dir + file'
|
// getting all file paths that match the pattern 'dir + file'
|
||||||
// path.Base make sure that file variable does not contains part of path
|
// 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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
Loading…
Reference in New Issue