net: Conn.Write() does not detect dropped TCP connection on the first attempt #20553
Labels
Comments
This'll be Nagel
…On Fri, 2 Jun 2017, 15:45 vbox ***@***.***> wrote:
What version of Go are you using (go version)?
go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kvs/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0
-fdebug-prefix-map=/tmp/go-build565879858=/tmp/go-bui
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
A dropped TCP connection does not get detected on the first Write(), but
detected on subsequent ones.
Steps to reproduce:
1.
Compile Go client -
https://gist.github.com/vbox/d6b8d3f431fd5195846929ee9659ed25
2.
Open TCP socket with nc:
nc -kl 5555
3.
Start client binary, and immediately after client has established
connection, kill nc. The client will attempt to write to a dropped
connection, but no error is generated.
What did you expect to see?
$ ./client
connection established
Write to server failed: write tcp 127.0.0.1:48176->127.0.0.1:5555: write:
broken pipe
What did you see instead?
$ ./client
connection established
writen to server = Halo
Write to server failed: write tcp 127.0.0.1:48176->127.0.0.1:5555: write:
broken pipe
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#20553>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAcAzgesSxDQV-hDzefmX7tOcUX40Knks5r_6FwgaJpZM4Nt2vv>
.
|
Your test code doesn't guarantee that the first write call that invokes some functionality inside the kernel has got a closed state of the underlying connection before it returns to the test code. On linux net/ipv4/tcp.c and tcp_output.c describe how the write system call interacts with the TCP implementation. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kvs/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build565879858=/tmp/go-bui
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
A dropped TCP connection does not get detected on the first Write(), but detected on subsequent ones.
Steps to reproduce:
Compile Go client - https://gist.github.com/vbox/d6b8d3f431fd5195846929ee9659ed25
Open TCP socket with nc:
nc -kl 5555
Start client binary, and immediately after client has established connection, kill nc. The client will attempt to write to a dropped connection, but no error is generated.
What did you expect to see?
$ ./client
connection established
Write to server failed: write tcp 127.0.0.1:48176->127.0.0.1:5555: write: broken pipe
What did you see instead?
$ ./client
connection established
writen to server = Halo
Write to server failed: write tcp 127.0.0.1:48176->127.0.0.1:5555: write: broken pipe
The text was updated successfully, but these errors were encountered: