Browse Source

Added continue statements after all state transitions in the state machine to ensure immediate state processing

pull/7421/head
chrislu 2 months ago
parent
commit
dcaa2686f4
  1. 7
      weed/s3api/chunked_reader_v4.go

7
weed/s3api/chunked_reader_v4.go

@ -256,6 +256,7 @@ func (cr *s3ChunkedReader) Read(buf []byte) (n int, err error) {
return 0, cr.err return 0, cr.err
} }
cr.state = readChunk cr.state = readChunk
continue
case readChunkTrailer: case readChunkTrailer:
err = peekCRLF(cr.reader) err = peekCRLF(cr.reader)
isTrailingChunk := cr.n == 0 && cr.lastChunk isTrailingChunk := cr.n == 0 && cr.lastChunk
@ -283,10 +284,13 @@ func (cr *s3ChunkedReader) Read(buf []byte) (n int, err error) {
// If we're using unsigned streaming upload, there is no signature to verify at each chunk. // If we're using unsigned streaming upload, there is no signature to verify at each chunk.
if cr.chunkSignature != "" { if cr.chunkSignature != "" {
cr.state = verifyChunk cr.state = verifyChunk
continue
} else if cr.lastChunk { } else if cr.lastChunk {
cr.state = readTrailerChunk cr.state = readTrailerChunk
continue
} else { } else {
cr.state = readChunkHeader cr.state = readChunkHeader
continue
} }
case readTrailerChunk: case readTrailerChunk:
@ -330,6 +334,7 @@ func (cr *s3ChunkedReader) Read(buf []byte) (n int, err error) {
} }
cr.state = eofChunk cr.state = eofChunk
continue
case readChunk: case readChunk:
// There is no more space left in the request buffer. // There is no more space left in the request buffer.
@ -404,8 +409,10 @@ func (cr *s3ChunkedReader) Read(buf []byte) (n int, err error) {
cr.chunkSHA256Writer.Reset() cr.chunkSHA256Writer.Reset()
if cr.lastChunk { if cr.lastChunk {
cr.state = eofChunk cr.state = eofChunk
continue
} else { } else {
cr.state = readChunkHeader cr.state = readChunkHeader
continue
} }
case eofChunk: case eofChunk:
return n, io.EOF return n, io.EOF

Loading…
Cancel
Save