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

Avoid discarding capacity during read operation #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vpzomtrrfrt
Copy link

The previous behaviour caused the target buffer length to change between calls within a single read operation, which seems wrong since the underlying read would then try to read too much into a smaller buffer

@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (5bf693f) 87.7% compared to head (b1c201b) 87.6%.

Additional details and impacted files
Files Coverage Δ
src/reader.rs 88.3% <93.3%> (+0.5%) ⬆️

... and 2 files with indirect coverage changes

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

Oooh, good catch! Your fix looks good — just left a note checking if we should also do the same recovery for the Err case.

return Poll::Ready(Err(io::Error::from(io::ErrorKind::BrokenPipe)));
match poll_reader(Pin::new(&mut self.reader), cx, &mut rest[..]) {
Poll::Ready(result) => {
let n = result?;
Copy link
Owner

Choose a reason for hiding this comment

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

I wonder if we should also recover the capacity if we hit an Err here? It's less likely to matter than the (common) Pending case, but might as well just handle it too.

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