From: Ian Lance Taylor Date: Sat, 28 Dec 2013 17:37:54 +0000 (-0800) Subject: net: work around Solaris connect issue when server closes socket X-Git-Tag: go1.3beta1~1098 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=672525a56e7d326ec986bc330a7accd8ec0395f4;p=gostls13.git net: work around Solaris connect issue when server closes socket On Solaris, if you do a in-progress connect, and then the server accepts and closes the socket, the client's later attempt to complete the connect will fail with EINVAL. Handle this case by assuming that the connect succeeded. This code is weird enough that it is implemented as Solaris-only so that it doesn't hide a real error on a different OS. Update #6828 R=golang-codereviews, bradfitz, dave CC=golang-codereviews https://golang.org/cl/46160043 --- diff --git a/src/pkg/net/fd_unix.go b/src/pkg/net/fd_unix.go index 9ed4f75364..ef44d44a99 100644 --- a/src/pkg/net/fd_unix.go +++ b/src/pkg/net/fd_unix.go @@ -80,6 +80,16 @@ func (fd *netFD) connect(la, ra syscall.Sockaddr) error { if err == nil || err == syscall.EISCONN { break } + + // On Solaris we can see EINVAL if the socket has + // already been accepted and closed by the server. + // Treat this as a successful connection--writes to + // the socket will see EOF. For details and a test + // case in C see http://golang.org/issue/6828. + if runtime.GOOS == "solaris" && err == syscall.EINVAL { + break + } + if err != syscall.EINPROGRESS && err != syscall.EALREADY && err != syscall.EINTR { return err }