]> Cypherpunks repositories - gostls13.git/commitdiff
net: avoid darwin_arm64 bug in TestDialParallelSpuriousConnection
authorDamien Neil <dneil@google.com>
Wed, 8 Jun 2022 18:53:22 +0000 (11:53 -0700)
committerDamien Neil <dneil@google.com>
Mon, 13 Jun 2022 19:00:03 +0000 (19:00 +0000)
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>

src/net/dial_test.go

index e49b4a61d611f74543e37842d38fc945cf4ef1bd..1256867da8db7777f0c9b6405cad546483f3288e 100644 (file)
@@ -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