better locking on file handle

This commit is contained in:
chrislu
2022-01-15 05:45:29 -08:00
parent 2bfeb5d1c8
commit 1bd6d289d4
2 changed files with 5 additions and 17 deletions

View File

@@ -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