fix(relay): wake the relay Listener on close #5491
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When closing a relayed
Listener
manually, theTransportEvent::ListenerClosed
generated by therelay::priv_client::Transport
is never forwarded back up to theSwarm
, causing theSwarm
to never remove the corresponding listener and never emitting theSwarmEvent::ListenerClosed
event.This happens because, when stopping a relayed listener manually, the call to the
close()
function, is done outside thepoll
function, which mean nothing is triggering a wake up call to wake up the polling.Unfortunately, even if the
listeners
(SelectAll
) is always polled after a call to theclose
method, sinceSelectAll
uses aFuturesUnordered
internally, the poll does nothing. Indeed, theFuturesUnordered
states that:Since means that when closing a relayed listener manually (calling
swarm.remove_listener
), it is never removed.This PR fixes that by triggering a
waker
when calling theclose
function.Notes & open questions
Change checklist