Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close the mtr channel from the sending location #1

Merged
merged 3 commits into from
Aug 2, 2021
Merged

Conversation

rdubrock
Copy link
Collaborator

No description provided.

@rdubrock rdubrock requested a review from mem July 28, 2021 21:12
Comment on lines +65 to +69
_, isOpen := <-ch
if !isOpen {
mu.Unlock()
return
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same logic is needed above on lines 47-49

I find it a little odd that a channel is returned on line 40 to be passed to m on lines 51 and 74.

I think what this should do is return a read only channel (<- chan struct{} instead of just chan struct{}) from mtr.NewMTR, and store the channel in the structure, and then close it before Run returns. Since Run would have access to the channel, it wouldn't need it as an argument.

render(m)
mu.Unlock()
}
}(ch)
m.Run(ch, COUNT)
close(ch)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something, I think this has no effect, as Run calls discover which closes the channel as the last thing it does.

pkg/mtr/mtr.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants