]> Cypherpunks repositories - gostls13.git/commitdiff
test/stress: fix a goroutine leak in threadRing stresstest
authorRobert Obryk <robryk@gmail.com>
Mon, 3 Jun 2013 14:07:31 +0000 (07:07 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 3 Jun 2013 14:07:31 +0000 (07:07 -0700)
Fixes #5527

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/9955043

test/stress/runstress.go

index b5adf6a4a5616c2e229c1ff65ed4ceafa1845ceb..76ab2a8b4faf918ccf6474e88be145c760b594e7 100644 (file)
@@ -114,11 +114,16 @@ func stressExec() {
        }
 }
 
-func ringf(in <-chan int, out chan<- int, donec chan<- bool) {
+func ringf(in <-chan int, out chan<- int, donec chan bool) {
        for {
-               n := <-in
+               var n int
+               select {
+               case <-donec:
+                       return
+               case n = <-in:
+               }
                if n == 0 {
-                       donec <- true
+                       close(donec)
                        return
                }
                out <- n - 1