-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Conversation
src/proto/streams/state.rs
Outdated
Idle => Err(ProtocolError.into()), | ||
Closed(..) => Ok(()), | ||
_ => { | ||
trace!("send_reset: HalfClosedRemote => 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.
copy pasta
src/proto/streams/streams.rs
Outdated
|
||
let stream = me.store.resolve(self.key); | ||
|
||
stream.state.is_recv_closed() && me.actions.recv.is_empty() |
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.
Is this correct? It seems to be checking that there are no buffered frames on the entire connection vs. stream?
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.
good catch
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 posted a few inline comments.
src/proto/streams/buffer.rs
Outdated
@@ -36,6 +36,14 @@ impl<B> Buffer<B> { | |||
slab: Slab::new(), | |||
} | |||
} | |||
|
|||
pub fn len(&self) -> usize { |
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.
Looks like these fns aren't used anymore?
src/proto/streams/recv.rs
Outdated
@@ -74,6 +74,14 @@ impl<B> Recv<B> where B: Buf { | |||
} | |||
} | |||
|
|||
pub fn is_empty(&self) -> bool { |
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.
These aren't used anymore either?
src/proto/streams/send.rs
Outdated
stream: &mut store::Ptr<B>) | ||
-> Result<(), ConnectionError> | ||
{ | ||
stream.state.send_reset(reason)?; |
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.
It looks like the reset will still be sent if the stream state is already closed (potentially reset already). Is this expected?
src/proto/streams/streams.rs
Outdated
|
||
let stream = me.store.resolve(self.key); | ||
|
||
stream.state.is_recv_closed() && stream.pending_recv.is_empty() |
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.
stream.pending_recv
could only contain a trailers frame, and is_recv_empty()
would return false, yet there are no more data frames?
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.
is it worth just tracking a bool for this?
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.
Actually, i think this is okay if it's only meant to determine whether eos may be set...
src/proto/streams/send.rs
Outdated
stream: &mut store::Ptr<B>) | ||
-> Result<(), ConnectionError> | ||
{ | ||
if !stream.state.is_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.
but it should perhaps be an error to send a reset on a closed stream...
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() |
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.
As per the comment thread below, this will return false
if the body is consumed and the next pending frame is a trailer.
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 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
Merging. #yolo |
No description provided.