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

implement CloseRead/CloseWrite #5

Merged
merged 1 commit into from
Sep 2, 2020
Merged

implement CloseRead/CloseWrite #5

merged 1 commit into from
Sep 2, 2020

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented May 28, 2019

Also, fix handling of reset after close. If the remote side sends an EOF and then an RST, we now only apply that to the write side of the stream.

Part of libp2p/go-libp2p-core#166.

NOTE: I've split the read/write logic here so, even if we decide to go with something else, it shouldn't be that much more work on top of this patch.

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

this looks fine, only (small, nitty) thing is to add some commentary/breaks to clarify the code in the selects.

stream.go Show resolved Hide resolved
stream.go Show resolved Hide resolved
stream.go Show resolved Hide resolved
bench_test.go Outdated
@@ -1,3 +1,4 @@
//+build !race
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit scary

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm. I actually meant to apply this to mplex, not here... (one of the benchmarks there fails if it's too slow).

Comment on lines +23 to +24
halfOpen halfStreamState = iota
halfClosed
Copy link
Contributor

Choose a reason for hiding this comment

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

comment on the direction of which half?

Copy link
Member Author

Choose a reason for hiding this comment

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

Either half. There's one state for each half.

}
}

func TestHalfClose(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would be good to also have a code path to test the HalfReset closing path

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean CloseRead?

Copy link
Member Author

Choose a reason for hiding this comment

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

(there's no half reset)

@Stebalien
Copy link
Member Author

Test issue caused by #33.

@Stebalien Stebalien merged commit 10c9119 into master Sep 2, 2020
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 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