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

Refactor Yamux::close to use ? #2677

Merged
merged 3 commits into from
May 31, 2022
Merged
Changes from 1 commit
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
19 changes: 13 additions & 6 deletions muxers/yamux/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,23 @@ where

fn close(&self, c: &mut Context<'_>) -> Poll<YamuxResult<()>> {
let mut inner = self.0.lock();
if let std::task::Poll::Ready(x) = Pin::new(&mut inner.control).poll_close(c) {
return Poll::Ready(x.map_err(YamuxError));

if let Poll::Ready(()) = Pin::new(&mut inner.control)
.poll_close(c)
.map_err(YamuxError)?
{
return Poll::Ready(Ok(()));
}
while let std::task::Poll::Ready(x) = inner.incoming.poll_next_unpin(c) {
match x {
Some(Ok(_)) => {} // drop inbound stream
Some(Err(e)) => return Poll::Ready(Err(e)),

while let Poll::Ready(_inbound_stream) =
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
while let Poll::Ready(_inbound_stream) =
while let Poll::Ready(inbound_stream) =

Why prefix inbound_stream with an _?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make it more obvious that it will be unused but I guess technically it is not unused!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried to improve this with 6eb64fe.

inner.incoming.poll_next_unpin(c)?
{
match _inbound_stream {
Some(_) => {} // drop inbound stream
None => return Poll::Ready(Ok(())),
}
}

Poll::Pending
}

Expand Down