mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 08:11:39 +00:00
fix(swarm): gracefully disable oneshot handler on dial upgrade errors
Resolves https://github.com/libp2p/rust-libp2p/issues/3269. Pull-Request: #3577.
This commit is contained in:
@ -458,7 +458,7 @@ impl<TUpgrErr> ConnectionHandlerUpgrErr<TUpgrErr> {
|
||||
|
||||
impl<TUpgrErr> fmt::Display for ConnectionHandlerUpgrErr<TUpgrErr>
|
||||
where
|
||||
TUpgrErr: fmt::Display,
|
||||
TUpgrErr: error::Error + 'static,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
@ -468,7 +468,10 @@ where
|
||||
ConnectionHandlerUpgrErr::Timer => {
|
||||
write!(f, "Timer error while opening a substream")
|
||||
}
|
||||
ConnectionHandlerUpgrErr::Upgrade(err) => write!(f, "{err}"),
|
||||
ConnectionHandlerUpgrErr::Upgrade(err) => {
|
||||
write!(f, "Upgrade: ")?;
|
||||
crate::print_error_chain(f, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -481,7 +484,7 @@ where
|
||||
match self {
|
||||
ConnectionHandlerUpgrErr::Timeout => None,
|
||||
ConnectionHandlerUpgrErr::Timer => None,
|
||||
ConnectionHandlerUpgrErr::Upgrade(err) => Some(err),
|
||||
ConnectionHandlerUpgrErr::Upgrade(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ where
|
||||
}
|
||||
ConnectionEvent::DialUpgradeError(DialUpgradeError { error, .. }) => {
|
||||
if self.pending_error.is_none() {
|
||||
self.pending_error = Some(error);
|
||||
log::debug!("DialUpgradeError: {error}");
|
||||
self.keep_alive = KeepAlive::No;
|
||||
}
|
||||
}
|
||||
ConnectionEvent::AddressChange(_) | ConnectionEvent::ListenUpgradeError(_) => {}
|
||||
|
Reference in New Issue
Block a user