From 2c52465cb3d327590755cfb9ef1ef0f7a167c4eb Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Wed, 8 Jun 2022 11:53:22 -0700 Subject: [PATCH] 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 Reviewed-by: Ian Lance Taylor Run-TryBot: Damien Neil --- src/net/dial_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/net/dial_test.go b/src/net/dial_test.go index e49b4a61d61..1256867da8d 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -405,6 +405,16 @@ func TestDialParallelSpuriousConnection(t *testing.T) { 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. c.SetReadDeadline(readDeadline) var b [1]byte