aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/filehandle.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2022-12-05 12:32:27 -0800
committerGitHub <noreply@github.com>2022-12-05 12:32:27 -0800
commitdac9c28d05cd61402cf5fbac42507b49b5a4f7a5 (patch)
treea0ca34e1f223df0b7ace31bd3a1155389611301c /weed/mount/filehandle.go
parent38479b6329ead2d2e35850bd894bf9d8e030f09f (diff)
downloadseaweedfs-dac9c28d05cd61402cf5fbac42507b49b5a4f7a5.tar.xz
seaweedfs-dac9c28d05cd61402cf5fbac42507b49b5a4f7a5.zip
Revert "refactor: moved to locked entry" (#4035)
* Revert "refactor: moved to locked entry" This reverts commit 94bc9afd9d3f8e049219c1cdc9f0d6e0eb4cf456. * only add LockedEntry, no changes to entryLock * fix compilation
Diffstat (limited to 'weed/mount/filehandle.go')
-rw-r--r--weed/mount/filehandle.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go
index 7281ede66..b6ec3d2da 100644
--- a/weed/mount/filehandle.go
+++ b/weed/mount/filehandle.go
@@ -8,16 +8,18 @@ import (
"golang.org/x/exp/slices"
"golang.org/x/sync/semaphore"
"math"
+ "sync"
)
type FileHandleId uint64
type FileHandle struct {
- fh FileHandleId
- counter int64
- entry *LockedEntry
- inode uint64
- wfs *WFS
+ fh FileHandleId
+ counter int64
+ entry *LockedEntry
+ entryLock sync.Mutex
+ inode uint64
+ wfs *WFS
// cache file has been written to
dirtyMetadata bool
@@ -69,6 +71,8 @@ func (fh *FileHandle) UpdateEntry(fn func(entry *filer_pb.Entry)) *filer_pb.Entr
}
func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) {
+ fh.entryLock.Lock()
+ defer fh.entryLock.Unlock()
if fh.entry == nil {
return