diff --git a/swarm-derive/src/lib.rs b/swarm-derive/src/lib.rs index 5f901ed6ff8..6899ba7d79d 100644 --- a/swarm-derive/src/lib.rs +++ b/swarm-derive/src/lib.rs @@ -125,7 +125,7 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> TokenStream { ) .unwrap(); let ty = &field.ty; - quote! {#variant(<#ty as ::libp2p::swarm::NetworkBehaviour>::OutEvent)} + quote! {#variant(<#ty as NetworkBehaviour>::OutEvent)} }) .collect::>(); let visibility = &ast.vis; diff --git a/transports/quic/src/endpoint.rs b/transports/quic/src/endpoint.rs index 3c34dd3b391..0f88f9860bd 100644 --- a/transports/quic/src/endpoint.rs +++ b/transports/quic/src/endpoint.rs @@ -40,7 +40,6 @@ use futures::{ use quinn_proto::{ClientConfig as QuinnClientConfig, ServerConfig as QuinnServerConfig}; use std::{ collections::HashMap, - fmt, net::{Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}, sync::Arc, task::{Context, Poll}, @@ -88,7 +87,7 @@ impl Config { } /// Object containing all the QUIC resources shared between all connections. -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Endpoint { /// Channel to the background of the endpoint. to_endpoint: mpsc::Sender, @@ -456,8 +455,9 @@ async fn background_task( return; } } - _ => tracing::warn!( - "Dropping new incoming connection because the channel to the listener is full." + Err(_) => tracing::warn!( + "Dropping new incoming connection {:?} because the channel to the listener is full", + connec_id ) } }, @@ -466,11 +466,3 @@ async fn background_task( } } } - -impl fmt::Debug for Endpoint { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Endpoint") - .field("socket_addr", &self.socket_addr) - .finish() - } -} diff --git a/transports/quic/src/muxer.rs b/transports/quic/src/muxer.rs index f2b6d3366bb..f9b5174dad9 100644 --- a/transports/quic/src/muxer.rs +++ b/transports/quic/src/muxer.rs @@ -195,25 +195,29 @@ impl StreamMuxer for QuicMuxer { } fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - let mut inner = self.inner.lock(); - if inner.connection.connection.is_drained() { + let Inner { + substreams, + connection, + .. + } = &mut *self.inner.lock(); + if connection.connection.is_drained() { return Poll::Ready(Ok(())); } - if inner.connection.connection.streams().send_streams() != 0 { - for substream in inner.substreams.keys().cloned().collect::>() { - if let Err(e) = inner.connection.finish_substream(substream) { + if connection.connection.streams().send_streams() != 0 { + for substream in substreams.keys() { + if let Err(e) = connection.finish_substream(*substream) { tracing::warn!("substream finish error on muxer close: {}", e); } } } loop { - if inner.connection.connection.streams().send_streams() == 0 - && !inner.connection.connection.is_closed() + if connection.connection.streams().send_streams() == 0 + && !connection.connection.is_closed() { - inner.connection.close() + connection.close() } - match inner.connection.poll_event(cx) { + match connection.poll_event(cx) { Poll::Ready(ConnectionEvent::ConnectionLost(_)) => return Poll::Ready(Ok(())), Poll::Ready(_) => {} Poll::Pending => break, diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index e915a29d532..40a7ba970fe 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -411,7 +411,7 @@ impl Stream for Listener { /// /// Returns `None` if the address is not the same socket family as the /// address that the endpoint is bound to. -pub fn ip_to_listenaddr(endpoint: &Endpoint, ip: IpAddr) -> Option { +fn ip_to_listenaddr(endpoint: &Endpoint, ip: IpAddr) -> Option { // True if either both addresses are Ipv4 or both Ipv6. let is_same_ip_family = endpoint.socket_addr().is_ipv4() == ip.is_ipv4(); if !is_same_ip_family {