Add detection for disconnections in mplex

This commit is contained in:
mhchia
2019-09-13 15:29:24 +08:00
parent 393b51a744
commit 2d8e02b7eb
7 changed files with 89 additions and 51 deletions

View File

@ -41,14 +41,8 @@ async def decode_uvarint_from_stream(reader: Reader) -> int:
if shift > SHIFT_64_BIT_MAX:
raise ParseError("TODO: better exception msg: Integer is too large...")
byte = await reader.read(1)
try:
value = byte[0]
except IndexError:
raise ParseError(
"Unexpected end of stream while parsing LEB128 encoded integer"
)
byte = await read_exactly(reader, 1)
value = byte[0]
res += (value & LOW_MASK) << shift