Commit a11d7d4e authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

net: prepare connect() for new network poller

The problem is that new network poller can have spurious
rediness notifications. This implementation ensures that
the socket is actually connected.

R=golang-dev, rsc, akumar
CC=golang-dev
https://golang.org/cl/7785043
parent ffbcd89f
......@@ -86,21 +86,19 @@ func (fd *netFD) connect(ra syscall.Sockaddr) error {
if err := fd.pd.PrepareWrite(); err != nil {
return err
}
err := syscall.Connect(fd.sysfd, ra)
if err == syscall.EINPROGRESS {
if err = fd.pd.WaitWrite(); err != nil {
return err
for {
err := syscall.Connect(fd.sysfd, ra)
if err == nil || err == syscall.EISCONN {
break
}
var e int
e, err = syscall.GetsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_ERROR)
if err != nil {
return os.NewSyscallError("getsockopt", err)
if err != syscall.EINPROGRESS && err != syscall.EALREADY && err != syscall.EINTR {
return err
}
if e != 0 {
err = syscall.Errno(e)
if err = fd.pd.WaitWrite(); err != nil {
return err
}
}
return err
return nil
}
// Add a reference to this fd.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment