mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
delete only when not used
This commit is contained in:
parent
1dc25218cd
commit
fcf5b6cc93
|
@ -100,10 +100,10 @@ func (cw *ChunkedStreamWriter) saveOneChunk(memChunk *MemChunk, logicChunkIndex
|
||||||
for t := memChunk.usage.head.next; t != memChunk.usage.tail; t = t.next {
|
for t := memChunk.usage.head.next; t != memChunk.usage.tail; t = t.next {
|
||||||
reader := util.NewBytesReader(memChunk.buf[t.StartOffset:t.stopOffset])
|
reader := util.NewBytesReader(memChunk.buf[t.StartOffset:t.stopOffset])
|
||||||
cw.saveToStorageFn(reader, int64(logicChunkIndex)*cw.ChunkSize+t.StartOffset, t.Size(), func() {
|
cw.saveToStorageFn(reader, int64(logicChunkIndex)*cw.ChunkSize+t.StartOffset, t.Size(), func() {
|
||||||
delete(cw.activeChunks, logicChunkIndex)
|
|
||||||
atomic.AddInt32(&referenceCounter, -1)
|
atomic.AddInt32(&referenceCounter, -1)
|
||||||
if atomic.LoadInt32(&referenceCounter) == 0 {
|
if atomic.LoadInt32(&referenceCounter) == 0 {
|
||||||
mem.Free(memChunk.buf)
|
mem.Free(memChunk.buf)
|
||||||
|
delete(cw.activeChunks, logicChunkIndex)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue