mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Fix possible memory leak by defer inside loop
This commit is contained in:
parent
e193579df8
commit
c999902761
|
@ -62,9 +62,9 @@ func (p *persistence) recoverFromCrash(fingerprintToSeries map[model.Fingerprint
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer dir.Close()
|
|
||||||
for fis := []os.FileInfo{}; err != io.EOF; fis, err = dir.Readdir(1024) {
|
for fis := []os.FileInfo{}; err != io.EOF; fis, err = dir.Readdir(1024) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
dir.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
|
@ -78,6 +78,7 @@ func (p *persistence) recoverFromCrash(fingerprintToSeries map[model.Fingerprint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dir.Close()
|
||||||
}
|
}
|
||||||
log.Infof("File scan complete. %d series found.", len(fpsSeen))
|
log.Infof("File scan complete. %d series found.", len(fpsSeen))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue