fix data race issue in unit testing of gtcp

This commit is contained in:
John 2019-12-13 14:26:07 +08:00
parent 2d754f80b1
commit 58a25c6f61

View File

@ -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)