-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
7527c51
to
85b53b3
Compare
85b53b3
to
7f5a301
Compare
There was a problem hiding this 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.
7f5a301
to
f8ae6b8
Compare
bench_test.go
Outdated
@@ -1,3 +1,4 @@ | |||
//+build !race |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
halfOpen halfStreamState = iota | ||
halfClosed |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean CloseRead
?
There was a problem hiding this comment.
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)
053f153
to
6ed2b1f
Compare
Test issue caused by #33. |
6ed2b1f
to
fa4a0b4
Compare
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.