Skip to content

Commit

Permalink
mfs: avoid flushing/syncing closed files.
Browse files Browse the repository at this point in the history
Technically, the sync could fail. If it does, we don't want to allow
syncing *again* without the write lock held.

License: MIT
Signed-off-by: Steven Allen <[email protected]>
  • Loading branch information
Stebalien committed Dec 21, 2017
1 parent feafd11 commit ed9a405
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mfs/fd.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@ func (fi *fileDescriptor) Close() error {
}

func (fi *fileDescriptor) Sync() error {
if fi.state == stateClosed {
return ErrClosed
}
return fi.flushUp(false)
}

func (fi *fileDescriptor) Flush() error {
if fi.state == stateClosed {
return ErrClosed
}
return fi.flushUp(true)
}

Expand Down

0 comments on commit ed9a405

Please sign in to comment.