Stop AfterFunc timer after findCmd.Wait regardless of errors to prevent memory leak
This commit is contained in:
parent
99716b05db
commit
4a778288ee
5
fs/fs.go
5
fs/fs.go
@ -603,10 +603,11 @@ func GetDirInodeUsage(dir string, timeout time.Duration) (uint64, error) {
|
|||||||
glog.Infof("killing cmd %v due to timeout(%s)", findCmd.Args, timeout.String())
|
glog.Infof("killing cmd %v due to timeout(%s)", findCmd.Args, timeout.String())
|
||||||
findCmd.Process.Kill()
|
findCmd.Process.Kill()
|
||||||
})
|
})
|
||||||
if err := findCmd.Wait(); err != nil {
|
err := findCmd.Wait()
|
||||||
|
timer.Stop()
|
||||||
|
if err != nil {
|
||||||
return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", findCmd.Args, stderr.String(), err)
|
return 0, fmt.Errorf("cmd %v failed. stderr: %s; err: %v", findCmd.Args, stderr.String(), err)
|
||||||
}
|
}
|
||||||
timer.Stop()
|
|
||||||
return counter.bytesWritten, nil
|
return counter.bytesWritten, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user