Browse Source

delete only when not used

avoid_releasing_temp_file_on_write
chrislu 3 years ago
parent
commit
fcf5b6cc93
  1. 2
      weed/filesys/page_writer/chunked_stream_writer.go

2
weed/filesys/page_writer/chunked_stream_writer.go

@ -100,10 +100,10 @@ func (cw *ChunkedStreamWriter) saveOneChunk(memChunk *MemChunk, logicChunkIndex
for t := memChunk.usage.head.next; t != memChunk.usage.tail; t = t.next {
reader := util.NewBytesReader(memChunk.buf[t.StartOffset:t.stopOffset])
cw.saveToStorageFn(reader, int64(logicChunkIndex)*cw.ChunkSize+t.StartOffset, t.Size(), func() {
delete(cw.activeChunks, logicChunkIndex)
atomic.AddInt32(&referenceCounter, -1)
if atomic.LoadInt32(&referenceCounter) == 0 {
mem.Free(memChunk.buf)
delete(cw.activeChunks, logicChunkIndex)
}
})
}

Loading…
Cancel
Save