From 5a9ae8615ee616b11460a046deaa6981b10d69ab Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 7 Dec 2020 13:35:24 +0100 Subject: Do not close connections immediately on close signal, await for remaining responses --- src/peering/basalt.rs | 12 +++++------- src/peering/fullmesh.rs | 10 ++++------ 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/peering') diff --git a/src/peering/basalt.rs b/src/peering/basalt.rs index 615b559..4aa34f6 100644 --- a/src/peering/basalt.rs +++ b/src/peering/basalt.rs @@ -3,7 +3,7 @@ use std::net::SocketAddr; use std::sync::{Arc, RwLock}; use std::time::Duration; -use log::{trace, debug, info, warn}; +use log::{debug, info, trace, warn}; use lru::LruCache; use rand::{thread_rng, Rng}; use serde::{Deserialize, Serialize}; @@ -267,15 +267,13 @@ impl Basalt { netapp.on_connected( move |pk: ed25519::PublicKey, addr: SocketAddr, is_incoming: bool| { basalt2.on_connected(pk, addr, is_incoming); - } + }, ); let basalt2 = basalt.clone(); - netapp.on_disconnected( - move |pk: ed25519::PublicKey, is_incoming: bool| { - basalt2.on_disconnected(pk, is_incoming); - }, - ); + netapp.on_disconnected(move |pk: ed25519::PublicKey, is_incoming: bool| { + basalt2.on_disconnected(pk, is_incoming); + }); let basalt2 = basalt.clone(); netapp.add_msg_handler::( diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs index 1b26489..d6ca08a 100644 --- a/src/peering/fullmesh.rs +++ b/src/peering/fullmesh.rs @@ -185,12 +185,10 @@ impl FullMeshPeeringStrategy { ); let strat2 = strat.clone(); - netapp.on_disconnected( - move |pk: ed25519::PublicKey, is_incoming: bool| { - let strat2 = strat2.clone(); - tokio::spawn(strat2.on_disconnected(pk, is_incoming)); - }, - ); + netapp.on_disconnected(move |pk: ed25519::PublicKey, is_incoming: bool| { + let strat2 = strat2.clone(); + tokio::spawn(strat2.on_disconnected(pk, is_incoming)); + }); strat } -- cgit v1.2.3