ensure releasing file handle

This commit is contained in:
chrislu 2022-03-07 14:01:24 -08:00
parent 8136384473
commit 3aeee3d748
3 changed files with 9 additions and 0 deletions

View file

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

View file

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

View file

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