Skip to content

Commit 2c52465

Browse files
committed
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>
1 parent 9228d7d commit 2c52465

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/net/dial_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,16 @@ func TestDialParallelSpuriousConnection(t *testing.T) {
405405
t.Fatal(err)
406406
}
407407

408+
// Workaround for https://go.dev/issue/37795.
409+
// On arm64 macOS (current as of macOS 12.4),
410+
// reading from a socket at the same time as the client
411+
// is closing it occasionally hangs for 60 seconds before
412+
// returning ECONNRESET. Sleep for a bit to give the
413+
// socket time to close before trying to read from it.
414+
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
415+
time.Sleep(10 * time.Millisecond)
416+
}
417+
408418
// The client should close itself, without sending data.
409419
c.SetReadDeadline(readDeadline)
410420
var b [1]byte

0 commit comments

Comments
 (0)