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

implement h2::server::Stream::send_reset(Reason) and Body::is_empty() #22

Merged
merged 17 commits into from
Aug 23, 2017

Conversation

olix0r
Copy link
Collaborator

@olix0r olix0r commented Aug 16, 2017

No description provided.

Idle => Err(ProtocolError.into()),
Closed(..) => Ok(()),
_ => {
trace!("send_reset: HalfClosedRemote => Closed");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copy pasta

@olix0r olix0r changed the title wip: implement h2::server::Stream::send_reset implement h2::server::Stream::send_reset(Reason) and Body::is_empty() Aug 18, 2017

let stream = me.store.resolve(self.key);

stream.state.is_recv_closed() && me.actions.recv.is_empty()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this correct? It seems to be checking that there are no buffered frames on the entire connection vs. stream?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch

Copy link
Collaborator

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

I posted a few inline comments.

@@ -36,6 +36,14 @@ impl<B> Buffer<B> {
slab: Slab::new(),
}
}

pub fn len(&self) -> usize {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like these fns aren't used anymore?

@@ -74,6 +74,14 @@ impl<B> Recv<B> where B: Buf {
}
}

pub fn is_empty(&self) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These aren't used anymore either?

stream: &mut store::Ptr<B>)
-> Result<(), ConnectionError>
{
stream.state.send_reset(reason)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the reset will still be sent if the stream state is already closed (potentially reset already). Is this expected?


let stream = me.store.resolve(self.key);

stream.state.is_recv_closed() && stream.pending_recv.is_empty()
Copy link
Collaborator

Choose a reason for hiding this comment

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

stream.pending_recv could only contain a trailers frame, and is_recv_empty() would return false, yet there are no more data frames?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is it worth just tracking a bool for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, i think this is okay if it's only meant to determine whether eos may be set...

@olix0r olix0r changed the base branch from master to new-send-flow-control August 18, 2017 22:18
stream: &mut store::Ptr<B>)
-> Result<(), ConnectionError>
{
if !stream.state.is_closed() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but it should perhaps be an error to send a reset on a closed stream...

@olix0r olix0r changed the base branch from new-send-flow-control to master August 21, 2017 22:55
src/lib.rs Outdated
impl<B: IntoBuf> Body<B> {
pub fn is_empty(&self) -> bool {
// If the recv side is closed and the receive queue is empty, the body is empty.
self.inner.is_recv_eos()
Copy link
Collaborator

Choose a reason for hiding this comment

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

As per the comment thread below, this will return false if the body is consumed and the next pending frame is a trailer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think that's correct fsvo is_empty. I intend to expose "is there a body at all" and not "is there remaining body to be consumed". i should probably rename this

@carllerche
Copy link
Collaborator

Merging. #yolo

@carllerche carllerche merged commit f839443 into master Aug 23, 2017
@carllerche carllerche deleted the ver/send-reset branch August 23, 2017 19:50
cxw620 pushed a commit to hanyu-dev/miku-h2 that referenced this pull request Jan 20, 2025
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.

2 participants