Skip to content

Commit

Permalink
fix potential goroutine leaks (#10057)
Browse files Browse the repository at this point in the history
Signed-off-by: Shihao Xia <charlesxsh@hotmail.com>
  • Loading branch information
charlesxsh committed Jan 5, 2022
1 parent 7015452 commit d26fd5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions discovery/legacymanager/manager_test.go
Expand Up @@ -668,13 +668,16 @@ func TestTargetUpdatesOrder(t *testing.T) {
discoveryManager.updatert = 100 * time.Millisecond

var totalUpdatesCount int
provUpdates := make(chan []*targetgroup.Group)
for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
if len(up) > 0 {
totalUpdatesCount += len(up)
}
}
provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount)

for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
}

for x := 0; x < totalUpdatesCount; x++ {
select {
Expand Down
7 changes: 5 additions & 2 deletions discovery/manager_test.go
Expand Up @@ -668,13 +668,16 @@ func TestTargetUpdatesOrder(t *testing.T) {
discoveryManager.updatert = 100 * time.Millisecond

var totalUpdatesCount int
provUpdates := make(chan []*targetgroup.Group)
for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
if len(up) > 0 {
totalUpdatesCount += len(up)
}
}
provUpdates := make(chan []*targetgroup.Group, totalUpdatesCount)

for _, up := range tc.updates {
go newMockDiscoveryProvider(up...).Run(ctx, provUpdates)
}

for x := 0; x < totalUpdatesCount; x++ {
select {
Expand Down

0 comments on commit d26fd5c

Please sign in to comment.