optimize MRF replication queue to avoid memory leaks (#18007)

This commit is contained in:
Harshavardhana
2023-09-11 20:59:11 -07:00
committed by GitHub
parent 9f7044aed0
commit 1df5e31706
2 changed files with 132 additions and 118 deletions

View File

@@ -1790,7 +1790,7 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off
return nil, err
}
odirectEnabled := globalAPIConfig.odirectEnabled() && s.oDirect
odirectEnabled := globalAPIConfig.odirectEnabled() && s.oDirect && length >= 0
var file *os.File
if odirectEnabled {
@@ -1822,6 +1822,10 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off
}
}
if length < 0 {
return file, nil
}
st, err := file.Stat()
if err != nil {
file.Close()
@@ -1889,10 +1893,6 @@ func (c closeWrapper) Close() error {
// CreateFile - creates the file.
func (s *xlStorage) CreateFile(ctx context.Context, volume, path string, fileSize int64, r io.Reader) (err error) {
if fileSize < -1 {
return errInvalidArgument
}
volumeDir, err := s.getVolDir(volume)
if err != nil {
return err
@@ -1929,7 +1929,7 @@ func (s *xlStorage) writeAllDirect(ctx context.Context, filePath string, fileSiz
return osErrToFileErr(err)
}
odirectEnabled := globalAPIConfig.odirectEnabled() && s.oDirect
odirectEnabled := globalAPIConfig.odirectEnabled() && s.oDirect && fileSize > 0
var w *os.File
if odirectEnabled {