Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/proto/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,13 @@ impl Recv {
Some(Event::Headers(Client(response))) => Poll::Ready(Ok(response)),
Some(_) => panic!("poll_response called after response returned"),
None => {
stream.state.ensure_recv_open()?;
if !stream.state.ensure_recv_open()? {
proto_err!(stream: "poll_response: stream={:?} is not opened;", stream.id);
return Poll::Ready(Err(Error::library_reset(
stream.id,
Reason::PROTOCOL_ERROR,
)));
}
Copy link
Member

Choose a reason for hiding this comment

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

So, if recv is NOT open, should it be returning a new empty response? Or is that an error in this context? It would be good to include a code comment here to remind us why, in either case.

Copy link
Contributor Author

@DDtKey DDtKey Jun 6, 2023

Choose a reason for hiding this comment

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

I was relying on similar logic here and here, it just forces to mark future as ready without error.

However, it's still not so clear what would be the more correct way, because Result<bool, Error> is confusing and probably should be refactored somehow. What I know for sure: bool shouldn't be ignored.

But for now I wanted to address the issue with simple & partially existed logic: if ensure_recv_open tells us it's not an error but stream is closed, it shouldn't be error. Otherwise we need to think how it can be refactored. Any ideas?

Copy link
Member

Choose a reason for hiding this comment

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

Hm. Is there a way to build a test for this? That might help make it clearer what should actually be done.


stream.recv_task = Some(cx.waker().clone());
Poll::Pending
Expand Down
6 changes: 5 additions & 1 deletion src/proto/streams/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,11 @@ impl Inner {
}

// The stream must be receive open
stream.state.ensure_recv_open()?;
if !stream.state.ensure_recv_open()? {
proto_err!(conn: "recv_push_promise: initiating stream is not opened");
return Err(Error::library_go_away(Reason::PROTOCOL_ERROR));
}

stream.key()
}
None => {
Expand Down