Remove the error when stopping the network (#8671)

This commit is contained in:
Pierre Krieger
2018-05-22 06:35:13 +02:00
committed by Marek Kotewicz
parent ee41fa6f30
commit fe5f5b28d9
5 changed files with 14 additions and 16 deletions

View File

@@ -396,7 +396,7 @@ impl Host {
format!("{}", Node::new(info.id().clone(), info.local_endpoint.clone()))
}
pub fn stop(&self, io: &IoContext<NetworkIoMessage>) -> Result<(), Error> {
pub fn stop(&self, io: &IoContext<NetworkIoMessage>) {
self.stopping.store(true, AtomicOrdering::Release);
let mut to_kill = Vec::new();
for e in self.sessions.read().iter() {
@@ -408,8 +408,7 @@ impl Host {
trace!(target: "network", "Disconnecting on shutdown: {}", p);
self.kill_connection(p, io, true);
}
io.unregister_handler()?;
Ok(())
io.unregister_handler();
}
/// Get all connected peers.

View File

@@ -125,15 +125,14 @@ impl NetworkService {
Ok(())
}
/// Stop network IO
pub fn stop(&self) -> Result<(), Error> {
/// Stop network IO.
pub fn stop(&self) {
let mut host = self.host.write();
if let Some(ref host) = *host {
let io = IoContext::new(self.io_service.channel(), 0); //TODO: take token id from host
host.stop(&io)?;
host.stop(&io);
}
*host = None;
Ok(())
}
/// Get a list of all connected peers by id.