]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
net: work around Solaris connect issue when server closes socket
authorIan Lance Taylor <ian@gcc.gnu.org>
Sat, 28 Dec 2013 18:00:30 +0000 (18:00 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sat, 28 Dec 2013 18:00:30 +0000 (18:00 +0000)
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.

See http://golang.org/issue/6828.

From-SVN: r206232

libgo/go/net/fd_unix.go

index 4911ab0abe3f3aac33211a61750c48f39d5b9a4d..a89303e37e9f3093998d0a4c51ea93bb74e12fc2 100644 (file)
@@ -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
                }