Skip to content
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

Merged
merged 5 commits into from
Feb 1, 2021
Merged

More stream reading improvements #999

merged 5 commits into from
Feb 1, 2021

Conversation

djc
Copy link
Member

@djc djc commented Jan 30, 2021

No description provided.

@djc djc changed the title Read next More stream reading improvements Jan 30, 2021
Copy link
Collaborator

@Ralith Ralith left a 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);
Copy link
Collaborator

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.

Copy link
Member Author

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?

quinn-proto/src/connection/assembler.rs Outdated Show resolved Hide resolved
quinn-proto/src/connection/assembler.rs Outdated Show resolved Hide resolved
quinn-proto/src/connection/assembler.rs Outdated Show resolved Hide resolved
/// 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated references to None

Comment on lines 242 to 244
if let Some(status) = &self.fused {
return ReadResult::from_status(*status);
}
Copy link
Collaborator

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),
};
Copy link
Collaborator

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?

Comment on lines 356 to 357
/// The stream has been stopped
Closed,
Copy link
Collaborator

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.

Comment on lines 245 to 248

let result = chunks.next(usize::MAX);
assert_eq!(result.status, ReadStatus::Finished);
assert_eq!(result.chunk, None);
Copy link
Collaborator

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?

.inner
.read(stream, true)?
.next(buf.remaining())
.map(|chunk| buf.put_slice(&chunk.bytes)))
Copy link
Collaborator

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.

@Ralith
Copy link
Collaborator

Ralith commented Jan 31, 2021

Looks like there'll be a bit of a rebase hazard with #1000. Shouldn't be disastrous, though.

@geieredgar
Copy link
Contributor

I would be fine with waiting until this PR is merged and then rebasing my changes on top of it.

@djc
Copy link
Member Author

djc commented Jan 31, 2021

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.

@djc
Copy link
Member Author

djc commented Jan 31, 2021

(I will take review comments for the last commit in consideration for the new PR as well, of course.)

@Ralith Ralith merged commit 3aca40b into main Feb 1, 2021
@Ralith Ralith deleted the read-next branch February 1, 2021 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants