mirror of
https://github.com/golang/go
synced 2024-11-27 05:11:22 -07:00
net: avoid darwin_arm64 bug in TestDialParallelSpuriousConnection
On darwin_arm64, reading from a socket at the same time as the other end is closing it will occasionally hang for 60 seconds before returning ECONNRESET. (This is a macOS issue, not a Go issue.) Work around this condition by adding a brief sleep before the read. Fixes #37795. Change-Id: I63f92b91fb297cd66f89cdab707583afd50ab9c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/411155 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com>
This commit is contained in:
parent
9228d7d7d5
commit
2c52465cb3
@ -405,6 +405,16 @@ func TestDialParallelSpuriousConnection(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for https://go.dev/issue/37795.
|
||||||
|
// On arm64 macOS (current as of macOS 12.4),
|
||||||
|
// reading from a socket at the same time as the client
|
||||||
|
// is closing it occasionally hangs for 60 seconds before
|
||||||
|
// returning ECONNRESET. Sleep for a bit to give the
|
||||||
|
// socket time to close before trying to read from it.
|
||||||
|
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
// The client should close itself, without sending data.
|
// The client should close itself, without sending data.
|
||||||
c.SetReadDeadline(readDeadline)
|
c.SetReadDeadline(readDeadline)
|
||||||
var b [1]byte
|
var b [1]byte
|
||||||
|
Loading…
Reference in New Issue
Block a user