From 58a25c6f6192b5bde358f6264a5cdf542214ba4a Mon Sep 17 00:00:00 2001 From: John Date: Fri, 13 Dec 2019 14:26:07 +0800 Subject: [PATCH] fix data race issue in unit testing of gtcp --- net/gtcp/gtcp_unit_pool_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/net/gtcp/gtcp_unit_pool_test.go b/net/gtcp/gtcp_unit_pool_test.go index 3cbaea6fe..e7bd7a495 100644 --- a/net/gtcp/gtcp_unit_pool_test.go +++ b/net/gtcp/gtcp_unit_pool_test.go @@ -27,10 +27,8 @@ func Test_Pool_Basic1(t *testing.T) { } }) go s.Run() - defer func() { - s.Close() - }() - time.Sleep(100 * time.Millisecond) + defer s.Close() + time.Sleep(500 * time.Millisecond) gtest.Case(t, func() { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) gtest.Assert(err, nil) @@ -49,10 +47,8 @@ func Test_Pool_Basic2(t *testing.T) { conn.Close() }) go s.Run() - defer func() { - s.Close() - }() - time.Sleep(100 * time.Millisecond) + defer s.Close() + time.Sleep(500 * time.Millisecond) gtest.Case(t, func() { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) gtest.Assert(err, nil)