Fix thread safety of EC decoding during concurrent preads (#3881)

(cherry picked from commit 0e74f1e467)
This commit is contained in:
daimin 2022-02-11 10:20:00 +08:00 committed by Wei-Chiu Chuang
parent 5b47b9f360
commit 9071c9646c
No known key found for this signature in database
GPG Key ID: B362E1C021854B9D
1 changed files with 3 additions and 3 deletions

View File

@ -81,7 +81,7 @@ public abstract class RawErasureDecoder {
* @param outputs output buffers to put decoded data into according to * @param outputs output buffers to put decoded data into according to
* erasedIndexes, ready for read after the call * erasedIndexes, ready for read after the call
*/ */
public void decode(ByteBuffer[] inputs, int[] erasedIndexes, public synchronized void decode(ByteBuffer[] inputs, int[] erasedIndexes,
ByteBuffer[] outputs) throws IOException { ByteBuffer[] outputs) throws IOException {
ByteBufferDecodingState decodingState = new ByteBufferDecodingState(this, ByteBufferDecodingState decodingState = new ByteBufferDecodingState(this,
inputs, erasedIndexes, outputs); inputs, erasedIndexes, outputs);
@ -130,7 +130,7 @@ public abstract class RawErasureDecoder {
* erasedIndexes, ready for read after the call * erasedIndexes, ready for read after the call
* @throws IOException if the decoder is closed. * @throws IOException if the decoder is closed.
*/ */
public void decode(byte[][] inputs, int[] erasedIndexes, byte[][] outputs) public synchronized void decode(byte[][] inputs, int[] erasedIndexes, byte[][] outputs)
throws IOException { throws IOException {
ByteArrayDecodingState decodingState = new ByteArrayDecodingState(this, ByteArrayDecodingState decodingState = new ByteArrayDecodingState(this,
inputs, erasedIndexes, outputs); inputs, erasedIndexes, outputs);
@ -163,7 +163,7 @@ public abstract class RawErasureDecoder {
* erasedIndexes, ready for read after the call * erasedIndexes, ready for read after the call
* @throws IOException if the decoder is closed * @throws IOException if the decoder is closed
*/ */
public void decode(ECChunk[] inputs, int[] erasedIndexes, public synchronized void decode(ECChunk[] inputs, int[] erasedIndexes,
ECChunk[] outputs) throws IOException { ECChunk[] outputs) throws IOException {
ByteBuffer[] newInputs = CoderUtil.toBuffers(inputs); ByteBuffer[] newInputs = CoderUtil.toBuffers(inputs);
ByteBuffer[] newOutputs = CoderUtil.toBuffers(outputs); ByteBuffer[] newOutputs = CoderUtil.toBuffers(outputs);