-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
p2p/host/basic/basic_host.go
Outdated
go func() { | ||
for { | ||
select { | ||
case <-h.addrChangeChan: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
p2p/host/basic/basic_host.go
Outdated
case <-p.Closing(): | ||
return | ||
} | ||
|
||
// emit an EvtLocalAddressesUpdatedEvent & a Push Identify if our listen addresses have changed. | ||
h.mx.Lock() |
There was a problem hiding this comment.
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.
There was a problem hiding this 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)
if !ok { | ||
return false | ||
if changeEvt != nil { | ||
err := h.emitters.evtLocalAddrsUpdated.Emit(*changeEvt) |
There was a problem hiding this comment.
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
For #848.