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

Upgrade libp2p-kad to stable futures #1254

Merged
merged 2 commits into from
Sep 26, 2019
Merged

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Sep 23, 2019

I didn't check if the tests were working (they're most likely not) because they depend on libp2p-yamux, which isn't upgraded yet.

@tomaka tomaka requested a review from romanb September 23, 2019 15:47
@@ -485,7 +484,10 @@ where
_ => false,
});
if let Some(pos) = pos {
let _ = self.substreams.remove(pos).try_close();
// TODO: we don't properly close down the substream
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is consistent with the current behaviour, but I realized that if the substream wasn't ready to be closed, we would just drop it immediately. That's not great.

Copy link
Contributor

Choose a reason for hiding this comment

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

That was intentional though, i.e. KademliaHandlerIn::Reset is just supposed to drop (reset) the substream. Trying to see if a close succeeds without blocking was just a "why not?", essentially. Do you see problems with this approach?

Copy link
Member Author

Choose a reason for hiding this comment

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

Closing a substream requires sending a message saying "close this substream" on the wire, and the closing process normally does that.

If a substream is dropped without being properly closed, the implementation of StreamMuxer can detect that and send the "close" message on the wire the next time it gets polled, but that's not an ideal way to do and I'm not sure that we're actually doing this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm ok with the current approach as long as we refactor it later with async/await.

@@ -103,29 +102,29 @@ where

impl<TSubstream, TUserData> SubstreamState<TSubstream, TUserData>
where
TSubstream: AsyncRead + AsyncWrite,
TSubstream: AsyncRead + AsyncWrite + Unpin,
{
/// Consumes this state and tries to close the substream.
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment "consumes this state" no longer matches the implementation (self -> &mut self).

@@ -485,7 +484,10 @@ where
_ => false,
});
if let Some(pos) = pos {
let _ = self.substreams.remove(pos).try_close();
// TODO: we don't properly close down the substream
Copy link
Contributor

Choose a reason for hiding this comment

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

That was intentional though, i.e. KademliaHandlerIn::Reset is just supposed to drop (reset) the substream. Trying to see if a close succeeds without blocking was just a "why not?", essentially. Do you see problems with this approach?

@tomaka tomaka merged commit 7f58684 into libp2p:stable-futures Sep 26, 2019
@tomaka tomaka deleted the kad-upgrade branch September 26, 2019 08:11
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