From 8e1a9c34ab7ae73f6c7d6fad10a37f1738a1e86a Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 22 Apr 2022 10:39:04 -0400 Subject: net: eliminate a deadlock on the failure path in TestNotTemporaryRead 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 Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/net/net_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/net/net_test.go b/src/net/net_test.go index fa5ad632bb..29a2c5d4ba 100644 --- a/src/net/net_test.go +++ b/src/net/net_test.go @@ -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") -- cgit v1.2.3-54-g00ecf