1
2
3
4
5
12
13 package main
14
15 import (
16 "context"
17 "os"
18 "runtime/pprof"
19 "time"
20 )
21
22 func init() {
23 register("Cockroach18101", Cockroach18101)
24 }
25
26 const chanSize_cockroach18101 = 6
27
28 func restore_cockroach18101(ctx context.Context) bool {
29 readyForImportCh := make(chan bool, chanSize_cockroach18101)
30 go func() {
31 defer close(readyForImportCh)
32 splitAndScatter_cockroach18101(ctx, readyForImportCh)
33 }()
34 for readyForImportSpan := range readyForImportCh {
35 select {
36 case <-ctx.Done():
37 return readyForImportSpan
38 }
39 }
40 return true
41 }
42
43 func splitAndScatter_cockroach18101(ctx context.Context, readyForImportCh chan bool) {
44 for i := 0; i < chanSize_cockroach18101+2; i++ {
45 readyForImportCh <- (false || i != 0)
46 }
47 }
48
49 func Cockroach18101() {
50 prof := pprof.Lookup("goroutineleak")
51 defer func() {
52 time.Sleep(100 * time.Millisecond)
53 prof.WriteTo(os.Stdout, 2)
54 }()
55 for i := 0; i < 100; i++ {
56 ctx, cancel := context.WithCancel(context.Background())
57 go restore_cockroach18101(ctx)
58 go cancel()
59 }
60 }
61
View as plain text