mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 16:21:39 +00:00
Don't allow handlers::poll() to return None (#811)
This commit is contained in:
@ -214,7 +214,7 @@ where
|
||||
fn poll(
|
||||
&mut self,
|
||||
) -> Poll<
|
||||
Option<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>>,
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>,
|
||||
io::Error,
|
||||
> {
|
||||
// Shortcut for polling a `tokio_timer::Delay`
|
||||
@ -234,7 +234,7 @@ where
|
||||
match mem::replace(&mut self.out_state, OutState::Poisoned) {
|
||||
OutState::Shutdown | OutState::Poisoned => {
|
||||
// This shuts down the whole connection with the remote.
|
||||
Ok(Async::Ready(None))
|
||||
Ok(Async::Ready(ProtocolsHandlerEvent::Shutdown))
|
||||
},
|
||||
|
||||
OutState::Disabled => {
|
||||
@ -246,12 +246,12 @@ where
|
||||
// Note that we ignore the expiration here, as it's pretty unlikely to happen.
|
||||
// The expiration is only here to be transmitted to the `Upgrading`.
|
||||
self.out_state = OutState::Upgrading { expires };
|
||||
Ok(Async::Ready(Some(
|
||||
Ok(Async::Ready(
|
||||
ProtocolsHandlerEvent::OutboundSubstreamRequest {
|
||||
upgrade: self.ping_config,
|
||||
info: (),
|
||||
},
|
||||
)))
|
||||
))
|
||||
}
|
||||
|
||||
// Waiting for the upgrade to be negotiated.
|
||||
@ -263,7 +263,7 @@ where
|
||||
Ready => {
|
||||
self.out_state = OutState::Shutdown;
|
||||
let ev = OutEvent::Unresponsive;
|
||||
Ok(Async::Ready(Some(ProtocolsHandlerEvent::Custom(ev))))
|
||||
Ok(Async::Ready(ProtocolsHandlerEvent::Custom(ev)))
|
||||
},
|
||||
}),
|
||||
|
||||
@ -278,12 +278,12 @@ where
|
||||
next_ping: Delay::new(Instant::now() + self.delay_to_next_ping),
|
||||
};
|
||||
let ev = OutEvent::PingSuccess(started.elapsed());
|
||||
return Ok(Async::Ready(Some(ProtocolsHandlerEvent::Custom(ev))));
|
||||
return Ok(Async::Ready(ProtocolsHandlerEvent::Custom(ev)));
|
||||
}
|
||||
Async::NotReady => {}
|
||||
Async::Ready(None) => {
|
||||
self.out_state = OutState::Shutdown;
|
||||
return Ok(Async::Ready(None));
|
||||
return Ok(Async::Ready(ProtocolsHandlerEvent::Shutdown));
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ where
|
||||
Ready => {
|
||||
self.out_state = OutState::Shutdown;
|
||||
let ev = OutEvent::Unresponsive;
|
||||
Ok(Async::Ready(Some(ProtocolsHandlerEvent::Custom(ev))))
|
||||
Ok(Async::Ready(ProtocolsHandlerEvent::Custom(ev)))
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -314,7 +314,7 @@ where
|
||||
let expires = Delay::new(Instant::now() + self.ping_timeout);
|
||||
substream.ping(Instant::now());
|
||||
self.out_state = OutState::WaitingForPong { substream, expires };
|
||||
Ok(Async::Ready(Some(ProtocolsHandlerEvent::Custom(OutEvent::PingStart))))
|
||||
Ok(Async::Ready(ProtocolsHandlerEvent::Custom(OutEvent::PingStart)))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ where
|
||||
fn poll(
|
||||
&mut self,
|
||||
) -> Poll<
|
||||
Option<ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>>,
|
||||
ProtocolsHandlerEvent<Self::OutboundProtocol, Self::OutboundOpenInfo, Self::OutEvent>,
|
||||
Self::Error,
|
||||
> {
|
||||
// Removes each substream one by one, and pushes them back if they're not ready (which
|
||||
@ -133,7 +133,7 @@ where
|
||||
|
||||
// Special case if shutting down.
|
||||
if self.shutdown && self.ping_in_substreams.is_empty() {
|
||||
return Ok(Async::Ready(None));
|
||||
return Ok(Async::Ready(ProtocolsHandlerEvent::Shutdown));
|
||||
}
|
||||
|
||||
Ok(Async::NotReady)
|
||||
|
Reference in New Issue
Block a user