fix(swarm): poll handler after injecting LocalProtocolsChange event

Previously, we would not call the handler upon injecting `ConnectionEvent::LocalProtocolsChange`. This would prevent protocols from being able to react to this change and e.g. issue events or open streams.

Pull-Request: #3979.
This commit is contained in:
Thomas Eizinger
2023-05-24 08:25:05 +02:00
committed by GitHub
parent ccb6e9586d
commit a424310d60

View File

@ -425,13 +425,18 @@ where
} }
let new_protocols = gather_supported_protocols(handler); let new_protocols = gather_supported_protocols(handler);
let changes = ProtocolsChange::from_full_sets(supported_protocols, &new_protocols);
for change in ProtocolsChange::from_full_sets(supported_protocols, &new_protocols) { if !changes.is_empty() {
for change in changes {
handler.on_connection_event(ConnectionEvent::LocalProtocolsChange(change)); handler.on_connection_event(ConnectionEvent::LocalProtocolsChange(change));
} }
*supported_protocols = new_protocols; *supported_protocols = new_protocols;
continue; // Go back to the top, handler can potentially make progress again.
}
return Poll::Pending; // Nothing can make progress, return `Pending`. return Poll::Pending; // Nothing can make progress, return `Pending`.
} }
} }