mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 09:11:34 +00:00
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:
@ -425,13 +425,18 @@ where
|
||||
}
|
||||
|
||||
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) {
|
||||
handler.on_connection_event(ConnectionEvent::LocalProtocolsChange(change));
|
||||
if !changes.is_empty() {
|
||||
for change in changes {
|
||||
handler.on_connection_event(ConnectionEvent::LocalProtocolsChange(change));
|
||||
}
|
||||
|
||||
*supported_protocols = new_protocols;
|
||||
|
||||
continue; // Go back to the top, handler can potentially make progress again.
|
||||
}
|
||||
|
||||
*supported_protocols = new_protocols;
|
||||
|
||||
return Poll::Pending; // Nothing can make progress, return `Pending`.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user