Skip to content

Commit fbf7e76

Browse files
tomakadarkfriend77
authored andcommitted
Fix bad state transition with DisabledPendingEnable+OpenDesiredByRemote (paritytech#7638)
1 parent 9d6bec0 commit fbf7e76

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

client/network/src/protocol/generic_proto/behaviour.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,34 +1575,20 @@ impl NetworkBehaviour for GenericProto {
15751575
}
15761576
}
15771577

1578-
// DisabledPendingEnable => DisabledPendingEnable | Incoming
1578+
// DisabledPendingEnable => Enabled | DisabledPendingEnable
15791579
PeerState::DisabledPendingEnable { mut connections, timer, timer_deadline } => {
15801580
if let Some((_, connec_state)) = connections.iter_mut().find(|(c, _)| *c == connection) {
15811581
if let ConnectionState::Closed = *connec_state {
1582-
*connec_state = ConnectionState::OpenDesiredByRemote;
1583-
1584-
let incoming_id = self.next_incoming_index;
1585-
self.next_incoming_index.0 = match self.next_incoming_index.0.checked_add(1) {
1586-
Some(v) => v,
1587-
None => {
1588-
error!(target: "sub-libp2p", "Overflow in next_incoming_index");
1589-
return
1590-
}
1591-
};
1592-
1593-
debug!(target: "sub-libp2p", "PSM <= Incoming({}, {:?}).",
1594-
source, incoming_id);
1595-
self.peerset.incoming(source.clone(), incoming_id);
1596-
self.incoming.push(IncomingPeer {
1582+
debug!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open",
1583+
source, connection);
1584+
self.events.push_back(NetworkBehaviourAction::NotifyHandler {
15971585
peer_id: source.clone(),
1598-
alive: true,
1599-
incoming_id,
1586+
handler: NotifyHandler::One(connection),
1587+
event: NotifsHandlerIn::Open,
16001588
});
1589+
*connec_state = ConnectionState::Opening;
16011590

1602-
*entry.into_mut() = PeerState::Incoming {
1603-
connections,
1604-
backoff_until: Some(timer_deadline),
1605-
};
1591+
*entry.into_mut() = PeerState::Enabled { connections };
16061592

16071593
} else {
16081594
// Connections in `OpeningThenClosing` are in a Closed phase, and

0 commit comments

Comments
 (0)