diff options
| author | chrislu <chris.lu@gmail.com> | 2022-08-26 16:49:51 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-08-26 16:49:51 -0700 |
| commit | 8dae81c5edaea2b25a79d49c4a08ffadfdc6fddc (patch) | |
| tree | ce1ef0be521398d06255a97eb531d97b7f940b47 /weed/mount/filehandle.go | |
| parent | e0f4366f4ca3259bfe582fb1dd8951f2005160ab (diff) | |
| parent | 5df105b1f94b8776d18159ae213da39299e2ea37 (diff) | |
| download | seaweedfs-8dae81c5edaea2b25a79d49c4a08ffadfdc6fddc.tar.xz seaweedfs-8dae81c5edaea2b25a79d49c4a08ffadfdc6fddc.zip | |
Merge branch 'master' of https://github.com/seaweedfs/seaweedfs
Diffstat (limited to 'weed/mount/filehandle.go')
| -rw-r--r-- | weed/mount/filehandle.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go index 8175c61f4..4595764ee 100644 --- a/weed/mount/filehandle.go +++ b/weed/mount/filehandle.go @@ -1,12 +1,14 @@ package mount import ( + "sync" + + "golang.org/x/exp/slices" + "github.com/seaweedfs/seaweedfs/weed/filer" "github.com/seaweedfs/seaweedfs/weed/glog" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util" - "golang.org/x/exp/slices" - "sync" ) type FileHandleId uint64 @@ -57,12 +59,20 @@ func (fh *FileHandle) GetEntry() *filer_pb.Entry { defer fh.entryLock.Unlock() return fh.entry } + func (fh *FileHandle) SetEntry(entry *filer_pb.Entry) { fh.entryLock.Lock() defer fh.entryLock.Unlock() fh.entry = entry } +func (fh *FileHandle) UpdateEntry(fn func(entry *filer_pb.Entry)) *filer_pb.Entry { + fh.entryLock.Lock() + defer fh.entryLock.Unlock() + fn(fh.entry) + return fh.entry +} + func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) { fh.entryLock.Lock() defer fh.entryLock.Unlock() |
