1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-16 00:04:40 +00:00

vfs: reduce memory use by embedding sync.Cond

This commit is contained in:
Nick Craig-Wood
2022-07-28 17:35:14 +01:00
parent 821e084f28
commit e749bc58f4
4 changed files with 10 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ type ReadFileHandle struct {
baseHandle
done func(ctx context.Context, err error)
mu sync.Mutex
cond *sync.Cond // cond lock for out of sequence reads
cond sync.Cond // cond lock for out of sequence reads
closed bool // set if handle has been closed
r *accounting.Account
readCalled bool // set if read has been called
@@ -63,7 +63,7 @@ func newReadFileHandle(f *File) (*ReadFileHandle, error) {
size: nonNegative(o.Size()),
sizeUnknown: o.Size() < 0,
}
fh.cond = sync.NewCond(&fh.mu)
fh.cond = sync.Cond{L: &fh.mu}
return fh, nil
}
@@ -267,7 +267,7 @@ func (fh *ReadFileHandle) readAt(p []byte, off int64) (n int, err error) {
maxBuf = len(p)
}
if gap := off - fh.offset; gap > 0 && gap < int64(8*maxBuf) {
waitSequential("read", fh.remote, fh.cond, fh.file.VFS().Opt.ReadWait, &fh.offset, off)
waitSequential("read", fh.remote, &fh.cond, fh.file.VFS().Opt.ReadWait, &fh.offset, off)
}
doSeek := off != fh.offset
if doSeek && fh.noSeek {