Merge pull request #12240 from avorima/fdusage_readdirnames

etcdserver: Use Readdirnames to count fds for FDUsage
This commit is contained in:
Gyuho Lee 2020-08-20 21:58:18 -07:00 committed by GitHub
commit 76993f1fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,13 +33,12 @@ func FDUsage() (uint64, error) {
} }
// countFiles reads the directory named by dirname and returns the count. // countFiles reads the directory named by dirname and returns the count.
// This is same as stdlib "io/ioutil.ReadDir" but without sorting.
func countFiles(dirname string) (uint64, error) { func countFiles(dirname string) (uint64, error) {
f, err := os.Open(dirname) f, err := os.Open(dirname)
if err != nil { if err != nil {
return 0, err return 0, err
} }
list, err := f.Readdir(-1) list, err := f.Readdirnames(-1)
f.Close() f.Close()
if err != nil { if err != nil {
return 0, err return 0, err