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

Defer closing stream for reading #32

Merged
merged 1 commit into from
May 3, 2021
Merged

Conversation

dennis-tra
Copy link
Contributor

Hey there,

I'm trying to bring https://github.com/mtojek/go-libp2p-webrtc-star up to date (fork) and now with updated dependencies, the transport test suite is failing.

I had a look at the test cases and noticed that there are reading attempts on already closed streams. I guess this wasn't a problem until go-libp2p v0.12.0:

Previously, Close() closed streams for writing, but left them open for reading.
[...]
In this release, Close now closes the stream for both reading and writing.

In this PR I just deferred closing the reading side.

@dennis-tra dennis-tra force-pushed the master branch 2 times, most recently from f2de233 to e24c08f Compare May 1, 2021 15:42
@@ -141,7 +141,7 @@ func SubtestBasic(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
t.Fatalf("failed to write enough data (a->b)")
return
}
err = s.Close()
err = s.CloseWrite()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a one-line if.

@@ -155,6 +155,12 @@ func SubtestBasic(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
if !bytes.Equal(testData, buf) {
t.Errorf("expected %s, got %s", testData, buf)
}

err = s.Close()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -265,7 +271,11 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd
t.Error("failed to write enough data (a->b)")
return
}
s.Close()
err = s.CloseWrite()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

... and here.

@@ -276,6 +286,12 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd
if !bytes.Equal(data, ret) {
t.Errorf("expected %q, got %q", string(data), string(ret))
}

err = s.Close()
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

and here.

@Stebalien Stebalien merged commit e70b77d into libp2p:master May 3, 2021
@aschmahmann aschmahmann mentioned this pull request Aug 23, 2021
62 tasks
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.

3 participants