]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix race in TestTCPStress
authorMikio Hara <mikioh.mikioh@gmail.com>
Tue, 22 Dec 2015 00:35:27 +0000 (09:35 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Tue, 22 Dec 2015 03:39:39 +0000 (03:39 +0000)
Fixes #13704.

Change-Id: I7afef5058fa88b0de41213cf46219b684369f47f
Reviewed-on: https://go-review.googlesource.com/18111
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/tcp_test.go

index 2191c91fa350ee3139b39d5e94592eba183ba92d..30c5762592e895096916814c1e3456db14bcca9a 100644 (file)
@@ -539,9 +539,12 @@ func TestTCPStress(t *testing.T) {
        if err != nil {
                t.Fatal(err)
        }
-       defer ln.Close()
+       done := make(chan bool)
        // Acceptor.
        go func() {
+               defer func() {
+                       done <- true
+               }()
                for {
                        c, err := ln.Accept()
                        if err != nil {
@@ -559,7 +562,6 @@ func TestTCPStress(t *testing.T) {
                        }(c)
                }
        }()
-       done := make(chan bool)
        for i := 0; i < conns; i++ {
                // Client connection.
                go func() {
@@ -583,4 +585,6 @@ func TestTCPStress(t *testing.T) {
        for i := 0; i < conns; i++ {
                <-done
        }
+       ln.Close()
+       <-done
 }