Browse Source

ensure releasing file handle

pull/2730/head
chrislu 3 years ago
parent
commit
3aeee3d748
  1. 4
      weed/mount/filehandle.go
  2. 2
      weed/mount/filehandle_map.go
  3. 3
      weed/mount/page_writer/upload_pipeline.go

4
weed/mount/filehandle.go

@ -88,6 +88,10 @@ func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) {
fh.chunkAddLock.Unlock()
}
func (fh *FileHandle) Release() {
fh.dirtyPages.Destroy()
}
func lessThan(a, b *filer_pb.FileChunk) bool {
if a.Mtime == b.Mtime {
return a.Fid.FileKey < b.Fid.FileKey

2
weed/mount/filehandle_map.go

@ -61,6 +61,7 @@ func (i *FileHandleToInode) ReleaseByInode(inode uint64) {
if fh.counter <= 0 {
delete(i.inode2fh, inode)
delete(i.fh2inode, fh.fh)
fh.Release()
}
}
}
@ -77,6 +78,7 @@ func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
if fhHandle.counter <= 0 {
delete(i.inode2fh, inode)
delete(i.fh2inode, fhHandle.fh)
fhHandle.Release()
}
}

3
weed/mount/page_writer/upload_pipeline.go

@ -179,4 +179,7 @@ func (up *UploadPipeline) moveToSealed(memChunk PageChunk, logicChunkIndex Logic
}
func (up *UploadPipeline) Shutdown() {
for logicChunkIndex, sealedChunk := range up.sealedChunks {
sealedChunk.FreeReference(fmt.Sprintf("%s uploadpipeline shutdown chunk %d", up.filepath, logicChunkIndex))
}
}
Loading…
Cancel
Save