quinn-proto: check for stopped assembler before reading data

I'm guessing these were missed when these new methods were added,
and it seems like they do present a bit of a layering violation.
This commit is contained in:
Dirkjan Ochtman
2021-01-25 20:55:23 +01:00
committed by Benjamin Saunders
parent 7947ad5854
commit f2d01fb2ad
@@ -95,6 +95,10 @@ impl Recv {
}
pub(super) fn read_chunk(&mut self, max_length: usize) -> StreamReadResult<Bytes> {
if self.assembler.is_stopped() {
return Err(ReadError::UnknownStream);
}
match self.assembler.read(max_length)? {
Some(bytes) => Ok(Some(bytes)),
None => self.read_blocked().map(|()| None),
@@ -105,6 +109,10 @@ impl Recv {
&mut self,
chunks: &mut [Bytes],
) -> Result<Option<ReadChunks>, ReadError> {
if self.assembler.is_stopped() {
return Err(ReadError::UnknownStream);
}
let mut out = ReadChunks { bufs: 0, read: 0 };
if chunks.is_empty() {
return Ok(Some(out));