vfs: don't remove file from writers until it is transferred

This means that the list of active writers is up to date
This commit is contained in:
Nick Craig-Wood 2017-11-18 11:55:39 +00:00
parent 1b22ee5b93
commit 321b6da7af
2 changed files with 4 additions and 2 deletions

View File

@ -143,7 +143,8 @@ func (fh *RWFileHandle) close() (err error) {
fh.closed = true fh.closed = true
rdwrMode := fh.flags & accessModeMask rdwrMode := fh.flags & accessModeMask
if rdwrMode != os.O_RDONLY { if rdwrMode != os.O_RDONLY {
fh.file.delWriter(fh) // leave writer open until file is transferred
defer fh.file.delWriter(fh)
} }
if !fh.opened { if !fh.opened {
// If read only then return // If read only then return

View File

@ -151,7 +151,8 @@ func (fh *WriteFileHandle) close() error {
return ECLOSED return ECLOSED
} }
fh.closed = true fh.closed = true
fh.file.delWriter(fh) // leave writer open until file is transferred
defer fh.file.delWriter(fh)
writeCloseErr := fh.pipeWriter.Close() writeCloseErr := fh.pipeWriter.Close()
err := <-fh.result err := <-fh.result
if err == nil { if err == nil {