Skip to content

Commit

Permalink
fix(swarm): poll handler after injecting LocalProtocolsChange event
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomaseizinger authored May 24, 2023
1 parent ccb6e95 commit a424310
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions swarm/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,17 @@ 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;
*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`.
}
Expand Down

0 comments on commit a424310

Please sign in to comment.