-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More stream reading improvements #999
Conversation
Be more precise about discarding all buffered state for stopped streams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work so far!
if !self.stopped { | ||
self.assembler.insert(frame.offset, frame.data); | ||
} else { | ||
self.assembler.set_bytes_read(end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we actually had a bug where this (or equivalent) wasn't being done previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, this is a bit of a behavior change. Would you like me to split it out of this commit?
/// all available data has been read. `max_length` may be used to restrict the maximum size | ||
/// of the returned `Bytes` (but `usize::MAX` is supported, too). | ||
/// | ||
/// Will keep returning `None` once no further data is available for reading. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated references to None
if let Some(status) = &self.fused { | ||
return ReadResult::from_status(*status); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
let mut rs = match streams.recv.remove(&id) { | ||
Some(rs) => rs, | ||
None => return Err(ReadableError::UnknownStream), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we missing a check for whether the stream is stopped here?
/// The stream has been stopped | ||
Closed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks redundant to the UnknownStream
case in ReadableError
; a stream can never become stopped mid-read. It's also confusingly named.
quinn-proto/src/tests/mod.rs
Outdated
|
||
let result = chunks.next(usize::MAX); | ||
assert_eq!(result.status, ReadStatus::Finished); | ||
assert_eq!(result.chunk, None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just check the status
of the prior call, rather than calling again?
quinn/src/streams.rs
Outdated
.inner | ||
.read(stream, true)? | ||
.next(buf.remaining()) | ||
.map(|chunk| buf.put_slice(&chunk.bytes))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent loss of specific errors, we must check the status, stash any terminal states locally, and generate a suitable error without calling inner.read
on the next poll. Similarly below.
Looks like there'll be a bit of a rebase hazard with #1000. Shouldn't be disastrous, though. |
I would be fine with waiting until this PR is merged and then rebasing my changes on top of it. |
Scoped this down again to remove the hard stuff (last commit) -- all the other comments should be addressed, so we can just get the simple stuff merged. @geieredgar thanks for being accomodating, I hope the rebase isn't too painful. |
(I will take review comments for the last commit in consideration for the new PR as well, of course.) |
No description provided.