From 4e9874f86e24381fa4305f939d78ed857fe416ca Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Thu, 9 Feb 2017 14:34:38 -0500 Subject: [PATCH] net/rpc: fix aliasing in TestAcceptExitAfterListenerClose TestRPC writes to newServer and newServerAddr guarded with a sync.Once. TestAcceptExitAfterListenerClose was overwriting those variables, which caused the second invocation of TestRPC within a single process to fail. A second invocation can occur as a result of running the test with multiple values for the -cpu flag. fixes #19001. Change-Id: I291bacf44aefb49c2264ca0290a28248c026f80e Reviewed-on: https://go-review.googlesource.com/36624 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick --- src/net/rpc/server_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/net/rpc/server_test.go b/src/net/rpc/server_test.go index 8369c9dec7..b94ea6f6ab 100644 --- a/src/net/rpc/server_test.go +++ b/src/net/rpc/server_test.go @@ -619,13 +619,13 @@ func TestErrorAfterClientClose(t *testing.T) { // Tests the fix to issue 11221. Without the fix, this loops forever or crashes. func TestAcceptExitAfterListenerClose(t *testing.T) { - newServer = NewServer() + newServer := NewServer() newServer.Register(new(Arith)) newServer.RegisterName("net.rpc.Arith", new(Arith)) newServer.RegisterName("newServer.Arith", new(Arith)) var l net.Listener - l, newServerAddr = listenTCP() + l, _ = listenTCP() l.Close() newServer.Accept(l) }