pass in bytes buffer to avoid possible race condition

related to https://github.com/seaweedfs/seaweedfs/issues/6180
This commit is contained in:
chrislu 2024-10-30 09:31:22 -07:00
parent 3feb66d0a1
commit 8802843511

View File

@ -100,7 +100,7 @@ func (fs *FilerServer) uploadReaderToChunks(reader io.Reader, startOffset int64,
}
wg.Add(1)
go func(offset int64) {
go func(offset int64, buf *bytes.Buffer) {
defer func() {
bufPool.Put(bytesBuffer)
<-bytesBufferLimitChan
@ -124,7 +124,7 @@ func (fs *FilerServer) uploadReaderToChunks(reader io.Reader, startOffset int64,
}
fileChunksLock.Unlock()
}
}(chunkOffset)
}(chunkOffset, bytesBuffer)
// reset variables for the next chunk
chunkOffset = chunkOffset + dataSize