proxy: fix an issue about half-closing net.TCPConn after io.Copy()#1598
Merged
sanimej merged 1 commit intomoby:masterfrom Jan 6, 2017
Merged
proxy: fix an issue about half-closing net.TCPConn after io.Copy()#1598sanimej merged 1 commit intomoby:masterfrom
sanimej merged 1 commit intomoby:masterfrom
Conversation
AkihiroSuda
commented
Dec 22, 2016
| from.CloseWrite() | ||
| } | ||
| } | ||
| to.CloseRead() |
Member
Author
There was a problem hiding this comment.
Contributor
|
Thanks @AkihiroSuda LGTM |
Contributor
|
pls rebase |
Fix moby/moby#27539 After io.Copy(to, from), we should call to.CloseWrite(), not to.CloseRead(). Without this fix, TestTCP4ProxyHalfClose (newly added in this commit) fails as follows: --- FAIL: TestTCP4ProxyHalfClose (0.00s) network_proxy_test.go:135: EOF Signed-off-by: Akihiro Suda <[email protected]>
14dac08 to
d94f688
Compare
Member
Author
|
done @aboch |
Member
Author
|
Test failure seems unrelated |
sanimej
reviewed
Jan 4, 2017
| @@ -48,7 +48,8 @@ func (proxy *TCPProxy) clientLoop(client *net.TCPConn, quit chan bool) { | |||
| from.CloseWrite() | |||
| } | |||
There was a problem hiding this comment.
This change looks good. Given that the half-close from either side is handled with the change do we still need this if block ? Also, from.CloseWrite() doesn't look correct here.
There was a problem hiding this comment.
if err, ok := err.(*net.OpError); ok && err.Err == syscall.EPIPE {
from.CloseWrite()
}
This looks unnecessary. But its not from this PR and can be addressed separately.
LGTM.
Member
Author
There was a problem hiding this comment.
Uh, thank you for the comment and sorry for I did not respond.. 😅
I will try to remove that block after some verification
AkihiroSuda
added a commit
to AkihiroSuda/libnetwork
that referenced
this pull request
Jan 12, 2017
Signed-off-by: Akihiro Suda <[email protected]>
sanimej
pushed a commit
that referenced
this pull request
Jan 20, 2017
proxy: clean up code (addendum to #1598)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to moby/moby#27539
After
io.Copy(to, from), we should callto.CloseWrite(), notto.CloseRead().Without this fix,
TestTCP4ProxyHalfClose(newly added in this commit) fails asfollows:
In this test, the client calls
Write(),CloseWrite(), thenRead(), and the server callsReadAll(), thenWrite().Without the fix, the client fails to
Read()because ofEOF.Signed-off-by: Akihiro Suda [email protected]