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

fix(yamux): set EoF when remote peer half closes the stream in yamux #1086

Merged
merged 19 commits into from
May 24, 2024

Conversation

diegomrsantos
Copy link
Collaborator

@diegomrsantos diegomrsantos commented Apr 22, 2024

  • remove unnecessary returnedEoF field
  • don't set isEoF when the local peer half closes the stream
  • add more logs
  • add test that closes the stream for writing but reads from it

@diegomrsantos diegomrsantos changed the title debug ping error fix: set EoF when remote peer half closes the stream in yamux Apr 26, 2024
@@ -442,7 +441,7 @@ proc cleanupChannel(m: Yamux, channel: YamuxChannel) {.async: (raises: []).} =
when defined(libp2p_yamux_metrics):
libp2p_yamux_channels.set(
m.lenBySrc(channel.isSrc).int64, [$channel.isSrc, $channel.peerId])
if channel.isReset and channel.recvWindow > 0:
if (channel.isReset or not channel.closedRemotely.completed()) and channel.recvWindow > 0:
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'm not sure about this new condition.

Copy link
Collaborator

@lchenut lchenut May 23, 2024

Choose a reason for hiding this comment

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

channel.closedRemotely is always completed after channel.join().
In theory, the only possible case is if we try to cancel, but cleanupChannel is async spawned, so we cannot cancel it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

channel.closedRemotely is always completed after channel.join().

Is it? remoteClosed is called only in reset and when a fin is received. It'd be probably better to rename this proc to a verb.

Copy link
Collaborator

Choose a reason for hiding this comment

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

channel.join() is completed after LPstream.closeImpl() is called.
LPStream.closeImpl() is called by actuallyClosed here, and it's called after checking if closedRemotely is completed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, reverting.

@diegomrsantos diegomrsantos marked this pull request as ready for review May 9, 2024 19:41
@diegomrsantos diegomrsantos changed the title fix: set EoF when remote peer half closes the stream in yamux fix(yamux): set EoF when remote peer half closes the stream in yamux May 10, 2024
@@ -11,6 +11,6 @@ COPY . nim-libp2p/

RUN \
cd nim-libp2p && \
nim c --skipProjCfg --skipParentCfg --NimblePath:./nimbledeps/pkgs -p:nim-libp2p -d:chronicles_log_level=WARN --threads:off ./tests/transport-interop/main.nim
nim c --skipProjCfg --skipParentCfg --NimblePath:./nimbledeps/pkgs -p:nim-libp2p -d:chronicles_log_level=WARN -d:chronicles_default_output_device=stderr --threads:off ./tests/transport-interop/main.nim
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is how it should be according to the test spec in test-plans. This is a bit unrelated to the current scope of the PR, but the PR itself was born from debugging this test and this change was necessary, otherwise, the test fails when increasing the log level. Ideally, it should be done in a different PR, but it is fine in this case.

Copy link
Collaborator

@lchenut lchenut left a comment

Choose a reason for hiding this comment

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

LGTM

@diegomrsantos diegomrsantos merged commit 2fa2c44 into master May 24, 2024
9 checks passed
@diegomrsantos diegomrsantos deleted the ping-test-error branch May 24, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants