mirror of
https://github.com/rclone/rclone.git
synced 2025-12-15 15:53:41 +00:00
vfs: reduce memory use by embedding sync.Cond
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
type WriteFileHandle struct {
|
||||
baseHandle
|
||||
mu sync.Mutex
|
||||
cond *sync.Cond // cond lock for out of sequence writes
|
||||
cond sync.Cond // cond lock for out of sequence writes
|
||||
closed bool // set if handle has been closed
|
||||
remote string
|
||||
pipeWriter *io.PipeWriter
|
||||
@@ -43,7 +43,7 @@ func newWriteFileHandle(d *Dir, f *File, remote string, flags int) (*WriteFileHa
|
||||
result: make(chan error, 1),
|
||||
file: f,
|
||||
}
|
||||
fh.cond = sync.NewCond(&fh.mu)
|
||||
fh.cond = sync.Cond{L: &fh.mu}
|
||||
fh.file.addWriter(fh)
|
||||
return fh, nil
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func (fh *WriteFileHandle) writeAt(p []byte, off int64) (n int, err error) {
|
||||
return 0, ECLOSED
|
||||
}
|
||||
if fh.offset != off {
|
||||
waitSequential("write", fh.remote, fh.cond, fh.file.VFS().Opt.WriteWait, &fh.offset, off)
|
||||
waitSequential("write", fh.remote, &fh.cond, fh.file.VFS().Opt.WriteWait, &fh.offset, off)
|
||||
}
|
||||
if fh.offset != off {
|
||||
fs.Errorf(fh.remote, "WriteFileHandle.Write: can't seek in file without --vfs-cache-mode >= writes")
|
||||
|
||||
Reference in New Issue
Block a user