]> Cypherpunks repositories - gostls13.git/commit
net: handle spurious netpoll wakeups in connect
authorIan Lance Taylor <iant@golang.org>
Thu, 15 Jun 2017 02:55:40 +0000 (19:55 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 15 Jun 2017 22:39:39 +0000 (22:39 +0000)
commitbf0f69220255941196c684f235727fd6dc747b5c
treeb2decb0eae86a448af37697a0f3ce0a33dbc084a
parentebcdda4732c629508fd91a4db04cfb0de516aa2f
net: handle spurious netpoll wakeups in connect

In some cases the netpoll code can cause a spurious wakeup. This is
normally harmless, as the woken up code simply retries the operation.
However, for connect, the test we were using to see whether the
connect had succeeded (setsockopt(SO_ERROR)) was not reliable in the
case of a spurious wakeup.  Change to using a reliable test (getpeername).
On Darwin we used a different technique: a second call to connect;
change Darwin to use getpeername as well.

Return the result of getpeername to avoid having to call it twice.

Fixes #19289.

Change-Id: I119ec8e7a41f482f1e590d4c65a37f6103fa22d9
Reviewed-on: https://go-review.googlesource.com/45815
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/fd_unix.go
src/net/fd_windows.go
src/net/sock_posix.go
src/net/tcpsock_unix_test.go