Commit 17177a0d authored by Mikio Hara's avatar Mikio Hara

net: fix data race in TestSocket{Conn,PacketConn}

Fixes #10891.

Change-Id: Ie432c9c5520ac29cea8fe6452628ec467567eea5
Reviewed-on: https://go-review.googlesource.com/10194Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 7bdb4a28
......@@ -49,8 +49,11 @@ func TestSocketConn(t *testing.T) {
defer c.Close()
const N = 3
var wg sync.WaitGroup
wg.Add(2 * N)
for i := 0; i < N; i++ {
go func(i int) {
defer wg.Done()
l := syscall.SizeofRtMsghdr + syscall.SizeofSockaddrInet4
if freebsd32o64 {
l += syscall.SizeofRtMetrics // see syscall/route_freebsd_32bit.go
......@@ -73,8 +76,6 @@ func TestSocketConn(t *testing.T) {
}
}(i + 1)
}
var wg sync.WaitGroup
wg.Add(N)
for i := 0; i < N; i++ {
go func() {
defer wg.Done()
......
......@@ -59,9 +59,12 @@ func TestSocketPacketConn(t *testing.T) {
defer c.Close()
const N = 3
var wg sync.WaitGroup
wg.Add(2 * N)
dst := &netlinkAddr{PID: 0}
for i := 0; i < N; i++ {
go func() {
defer wg.Done()
l := syscall.NLMSG_HDRLEN + syscall.SizeofRtGenmsg
b := make([]byte, l)
*(*uint32)(unsafe.Pointer(&b[0:4][0])) = uint32(l)
......@@ -76,8 +79,6 @@ func TestSocketPacketConn(t *testing.T) {
}
}()
}
var wg sync.WaitGroup
wg.Add(N)
for i := 0; i < N; i++ {
go func() {
defer wg.Done()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment