From ce391f4ebe4f33b055ae4b2d89baa1ecf3dda551 Mon Sep 17 00:00:00 2001 From: bochaco Date: Tue, 27 Dec 2022 15:03:53 -0300 Subject: [PATCH 1/2] refactor: some code and log msgs minor improvements --- src/connection.rs | 15 ++++++++++----- src/endpoint.rs | 33 ++++++++++++++++----------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/connection.rs b/src/connection.rs index e118881c..e675ad7a 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -154,9 +154,11 @@ fn listen_on_uni_streams(connection: quinn::Connection, tx: Sender) let uni = connection.accept_uni().await.map_err(ConnectionError::from); let mut recv = match uni { Ok(recv) => recv, - // In case of a connection error, there is not much we can do. Err(err) => { - trace!("Connection {conn_id}: incoming uni-stream: ERROR: {err}"); + // In case of a connection error, there is not much we can do. + trace!( + "Connection {conn_id}: failure when awaiting incoming uni-streams: {err:?}" + ); // WARNING: This might block! let _ = tx.send(Err(RecvError::ConnectionLost(err))).await; break; @@ -204,9 +206,11 @@ fn listen_on_bi_streams( let bi = connection.accept_bi().await.map_err(ConnectionError::from); let (send, mut recv) = match bi { Ok(recv) => recv, - // In case of a connection error, there is not much we can do. Err(err) => { - trace!("Connection {conn_id}: incoming bi-stream: ERROR: {err:?}"); + // In case of a connection error, there is not much we can do. + trace!( + "Connection {conn_id}: failure when awaiting incoming bi-streams: {err:?}" + ); // WARNING: This might block! let _ = tx.send(Err(RecvError::ConnectionLost(err))).await; break; @@ -248,9 +252,10 @@ fn listen_on_bi_streams( }; // Pass the stream, so it can be used to respond to the user message. - let msg = msg.map(|msg| (msg, Some(SendStream::new(send, conn_id)))); + let msg = msg.map(|msg| (msg, Some(SendStream::new(send, conn_id.clone())))); // Send away the msg or error let _ = tx.send(msg).await; + trace!("Incoming new msg on conn_id={conn_id} sent to user in upper layer"); }); } diff --git a/src/endpoint.rs b/src/endpoint.rs index b3d4ec4c..1cdf7d34 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -24,7 +24,7 @@ use tracing::{error, info, trace, warn}; const ECHO_SERVICE_QUERY_TIMEOUT: Duration = Duration::from_secs(30); /// Standard size of our channel bounds -const STANDARD_CHANNEL_SIZE: usize = 10000; +const STANDARD_CHANNEL_SIZE: usize = 10_000; /// Channel on which incoming connections are notified on #[derive(Debug)] @@ -406,26 +406,25 @@ pub(super) fn listen_for_incoming_connections( connection_tx: mpsc::Sender<(Connection, ConnectionIncoming)>, ) { let _ = tokio::spawn(async move { - loop { - match quinn_endpoint.accept().await { - Some(quinn_conn) => match quinn_conn.await { - Ok(connection) => { - let connection = Connection::new(connection, quinn_endpoint.clone()); - let conn_id = connection.0.id(); - if connection_tx.send(connection).await.is_err() { - warn!("Dropping incoming connection conn_id={conn_id}, because receiver was dropped"); - } + while let Some(quinn_conn) = quinn_endpoint.accept().await { + match quinn_conn.await { + Ok(connection) => { + let connection = Connection::new(connection, quinn_endpoint.clone()); + let conn_id = connection.0.id(); + trace!("Incoming new connection conn_id={conn_id}"); + if connection_tx.send(connection).await.is_err() { + warn!("Dropping incoming connection conn_id={conn_id}, because receiver was dropped"); } - Err(err) => { - warn!("An incoming connection failed because of: {:?}", err); - } - }, - None => { - trace!("quinn::Incoming::next() returned None. There will be no more incoming connections"); - break; + } + Err(err) => { + warn!("An incoming connection failed because of: {:?}", err); } } } + + trace!( + "quinn::Endpoint::accept() returned None. There will be no more incoming connections" + ); }); } From e33ded14af97ec94fa789e39f5c2bc14d8c38b57 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 27 Dec 2022 21:09:05 +0000 Subject: [PATCH 2/2] chore(release): 0.34.2 --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 060f785c..19ec99c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [0.34.2](https://github.com/maidsafe/qp2p/compare/v0.34.1...v0.34.2) (2022-12-27) + ### [0.34.1](https://github.com/maidsafe/qp2p/compare/v0.34.0...v0.34.1) (2022-12-22) diff --git a/Cargo.toml b/Cargo.toml index 3957c942..db9ea4c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://maidsafe.net" license = "MIT OR BSD-3-Clause" readme = "README.md" repository = "https://github.com/maidsafe/qp2p" -version = "0.34.1" +version = "0.34.2" authors = [ "MaidSafe Developers " ] keywords = [ "quic" ] edition = "2021"