From b247f02c2907def0b569c958a589754dddc31012 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 4 Dec 2020 17:12:10 +0100 Subject: [PATCH] Don't close connection at first (stupid) excuse --- examples/fullmesh.rs | 1 + src/conn.rs | 8 ++++++-- src/peering/basalt.rs | 12 ++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/fullmesh.rs b/examples/fullmesh.rs index a24d343..dfacb89 100644 --- a/examples/fullmesh.rs +++ b/examples/fullmesh.rs @@ -1,4 +1,5 @@ use std::net::SocketAddr; +use std::io::Write; use log::info; diff --git a/src/conn.rs b/src/conn.rs index 7f869e8..d4362e5 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -216,7 +216,9 @@ impl ClientConn { if let Some((id, resp)) = resp { trace!("dispatch_resp: got resp to {}, {} bytes", id, resp.len()); if let Some(ch) = resp_notify.remove(&id) { - ch.send(resp).map_err(|_| Error::Message("Could not dispatch reply".to_string()))?; + if ch.send(resp).is_err() { + debug!("Could not dispatch reply (channel probably closed, happens if request was canceled)"); + } } else { resps.insert(id, resp); } @@ -226,7 +228,9 @@ impl ClientConn { if let Some((id, resp_ch)) = resp_ch { trace!("dispatch_resp: got resp_ch {}", id); if let Some(rs) = resps.remove(&id) { - resp_ch.send(rs).map_err(|_| Error::Message("Could not dispatch reply".to_string()))?; + if resp_ch.send(rs).is_err() { + debug!("Could not dispatch reply (channel probably closed, happens if request was canceled)"); + } } else { resp_notify.insert(id, resp_ch); } diff --git a/src/peering/basalt.rs b/src/peering/basalt.rs index 8849f41..615b559 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::{debug, info, warn}; +use log::{trace, debug, info, warn}; use lru::LruCache; use rand::{thread_rng, Rng}; use serde::{Deserialize, Serialize}; @@ -303,7 +303,7 @@ impl Basalt { .sample(count) .iter() .map(|p| { - info!("KYEV S {}", hex::encode(p.id)); + debug!("KYEV S {}", hex::encode(p.id)); p.id }) .collect::>() @@ -339,7 +339,7 @@ impl Basalt { { Ok(resp) => { self.handle_peer_list(&resp.peers[..]); - info!("KYEV PEXi {}", hex::encode(peer)); + trace!("KYEV PEXi {}", hex::encode(peer)); } Err(e) => { warn!("Error during pull exchange: {}", e); @@ -351,7 +351,7 @@ impl Basalt { let push_msg = self.make_push_message(); match self.netapp.request(&peer, push_msg, PRIO_NORMAL).await { Ok(_) => { - info!("KYEV PEXo {}", hex::encode(peer)); + trace!("KYEV PEXo {}", hex::encode(peer)); } Err(e) => { warn!("Error during push exchange: {}", e); @@ -371,7 +371,7 @@ impl Basalt { tokio::time::delay_for(self.param.reset_interval).await; { - info!("KYEV R {}", self.param.reset_count); + debug!("KYEV R {}", self.param.reset_count); let mut view = self.view.write().unwrap(); let prev_peers = view.current_peers(); @@ -419,7 +419,7 @@ impl Basalt { attempts.insert(peer); } let res = self.netapp.clone().try_connect(peer.addr, peer.id).await; - debug!("Connection attempt to {}: {:?}", peer.addr, res); + trace!("Connection attempt to {}: {:?}", peer.addr, res); self.current_attempts.write().unwrap().remove(&peer);