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

Signal address change #851

Merged
merged 4 commits into from
Mar 24, 2020
Merged

Signal address change #851

merged 4 commits into from
Mar 24, 2020

Conversation

aarshkshah1992
Copy link
Contributor

@aarshkshah1992 aarshkshah1992 commented Mar 24, 2020

go func() {
for {
select {
case <-h.addrChangeChan:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you not incorporate this into the below for() loop on the background goroutine, rather than adding the additional event loop for translating this event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, have made the change.

p2p/host/basic/basic_host.go Show resolved Hide resolved
Copy link
Contributor

@willscott willscott left a comment

Choose a reason for hiding this comment

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

Make sure this didn't introduce the data race at teardown the CI caught, and clean up the mutex that isn't needed any more. looks good otherwise.

case <-p.Closing():
return
}

// emit an EvtLocalAddressesUpdatedEvent & a Push Identify if our listen addresses have changed.
h.mx.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

mutex can be removed fully now that it's replaced with a channel.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

LGTM. (no need to address my comment, just something to consider later)

p2p/host/basic/basic_host.go Show resolved Hide resolved
if !ok {
return false
if changeEvt != nil {
err := h.emitters.evtLocalAddrsUpdated.Emit(*changeEvt)
Copy link
Member

Choose a reason for hiding this comment

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

nit: we don't even need to store this emitter in the host, we can just create it and close it within this loop.

@Stebalien Stebalien merged commit 6e97b5d into master Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants