aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/wfs.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-01-15 05:45:29 -0800
committerchrislu <chris.lu@gmail.com>2022-01-15 05:45:29 -0800
commit1bd6d289d48ea3ae3c1461bf090ce0ffa6f2505f (patch)
tree50983443038b5c4f0fab037febd136037d54f7a3 /weed/filesys/wfs.go
parent2bfeb5d1c81744c7aafacee84e15f25f87c50614 (diff)
downloadseaweedfs-1bd6d289d48ea3ae3c1461bf090ce0ffa6f2505f.tar.xz
seaweedfs-1bd6d289d48ea3ae3c1461bf090ce0ffa6f2505f.zip
better locking on file handle
Diffstat (limited to 'weed/filesys/wfs.go')
-rw-r--r--weed/filesys/wfs.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go
index f6a6031d2..54eb9064b 100644
--- a/weed/filesys/wfs.go
+++ b/weed/filesys/wfs.go
@@ -187,15 +187,15 @@ func (wfs *WFS) Fsync(file *File, header fuse.Header) error {
existingHandle, found := wfs.handles[inodeId]
wfs.handlesLock.Unlock()
- if found && existingHandle != nil && existingHandle.f.isOpen > 0 {
-
- existingHandle.Add(1)
- defer existingHandle.Done()
+ if found && existingHandle != nil {
existingHandle.Lock()
defer existingHandle.Unlock()
- return existingHandle.doFlush(context.Background(), header)
+ if existingHandle.f.isOpen > 0 {
+ return existingHandle.doFlush(context.Background(), header)
+ }
+
}
return nil