mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
fix data race issue in unit testing of gtcp
This commit is contained in:
parent
f4e8fbe767
commit
2d754f80b1
@ -52,7 +52,7 @@ func NewServer(address string, handler func(*Conn), name ...string) *Server {
|
||||
address: address,
|
||||
handler: handler,
|
||||
}
|
||||
if len(name) > 0 {
|
||||
if len(name) > 0 && name[0] != "" {
|
||||
serverMapping.Set(name[0], s)
|
||||
}
|
||||
return s
|
||||
|
@ -27,7 +27,9 @@ func Test_Pool_Basic1(t *testing.T) {
|
||||
}
|
||||
})
|
||||
go s.Run()
|
||||
defer s.Close()
|
||||
defer func() {
|
||||
s.Close()
|
||||
}()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
gtest.Case(t, func() {
|
||||
conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p))
|
||||
@ -47,7 +49,9 @@ func Test_Pool_Basic2(t *testing.T) {
|
||||
conn.Close()
|
||||
})
|
||||
go s.Run()
|
||||
defer s.Close()
|
||||
defer func() {
|
||||
s.Close()
|
||||
}()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
gtest.Case(t, func() {
|
||||
conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p))
|
||||
|
@ -154,7 +154,7 @@ func (c *Conn) Recv(length int, retry ...Retry) ([]byte, error) {
|
||||
if retry[0].Interval == 0 {
|
||||
retry[0].Interval = gDEFAULT_RETRY_INTERVAL
|
||||
}
|
||||
time.Sleep(time.Duration(retry[0].Interval) * time.Millisecond)
|
||||
time.Sleep(retry[0].Interval)
|
||||
continue
|
||||
}
|
||||
break
|
||||
|
@ -53,7 +53,7 @@ func NewServer(address string, handler func(*Conn), name ...string) *Server {
|
||||
address: address,
|
||||
handler: handler,
|
||||
}
|
||||
if len(name) > 0 {
|
||||
if len(name) > 0 && name[0] != "" {
|
||||
serverMapping.Set(name[0], s)
|
||||
}
|
||||
return s
|
||||
|
Loading…
Reference in New Issue
Block a user