diff options
author | Jakob Unterwurzacher | 2016-05-08 23:16:40 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-05-08 23:21:20 +0200 |
commit | ba7c798418269e6d496af206bdebd2204a07155f (patch) | |
tree | b1dcb3fc9d4219ddeaaf721339ee6d96a012e598 /internal | |
parent | 4b6cf43521a362ff36e38aa77b48ee06fdf11f71 (diff) |
fusefrontend: fix panic due to concurrently unregistered wlock
Commit 730291feab properly freed wlock when the file descriptor is
closed. However, concurrently running Write and Truncates may
still want to lock it. Check if the fd has been closed first.
Diffstat (limited to 'internal')
-rw-r--r-- | internal/fusefrontend/file.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index d9588e9..ac00b1d 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -278,6 +278,10 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) { func (f *file) Write(data []byte, off int64) (uint32, fuse.Status) { f.fdLock.RLock() defer f.fdLock.RUnlock() + if f.fd.Fd() < 0 { + // The file descriptor has been closed concurrently. + return 0, fuse.EBADF + } wlock.lock(f.ino) defer wlock.unlock(f.ino) @@ -337,6 +341,10 @@ func (f *file) Fsync(flags int) (code fuse.Status) { func (f *file) Truncate(newSize uint64) fuse.Status { f.fdLock.RLock() defer f.fdLock.RUnlock() + if f.fd.Fd() < 0 { + // The file descriptor has been closed concurrently. + return fuse.EBADF + } wlock.lock(f.ino) defer wlock.unlock(f.ino) |