]> Cypherpunks repositories - gostls13.git/commitdiff
net: eliminate a deadlock on the failure path in TestNotTemporaryRead
authorBryan C. Mills <bcmills@google.com>
Fri, 22 Apr 2022 14:39:04 +0000 (10:39 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 22 Apr 2022 21:27:09 +0000 (21:27 +0000)
This fixes a deadlock-on-failure that I probably introduced in
CL 385314.

This doesn't explain why the failure observed in #52492 occurred, but
it will at least give us more information to diagnose the failure if
it happens again. (The deadlock currently prevents the t.Fatal log
message from being written to the test's output.)

Fixes #52492.

Change-Id: I9e7874985e2820a6a4b703abe4f8e2035d5138c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/401575
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/net/net_test.go

index fa5ad632bbe5ff0eeea6785a8b9674038d3f2773..29a2c5d4baa2308eb56bcad58b4a05f271038038 100644 (file)
@@ -529,17 +529,19 @@ func TestNotTemporaryRead(t *testing.T) {
                <-dialed
                cs.(*TCPConn).SetLinger(0)
                cs.Close()
-
+       }()
+       defer func() {
                ln.Close()
+               <-serverDone
        }()
-       defer func() { <-serverDone }()
 
        ss, err := Dial("tcp", ln.Addr().String())
+       close(dialed)
        if err != nil {
                t.Fatal(err)
        }
        defer ss.Close()
-       close(dialed)
+
        _, err = ss.Read([]byte{0})
        if err == nil {
                t.Fatal("Read succeeded unexpectedly")