From 1be34fd7a363b04a985b596abf0dba4941ae9a01 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 28 Apr 2020 16:18:35 +0200 Subject: [PATCH] protocols/gossipsub: Correct max transmit size error handling (#1558) If a user sends a message that is over the maximum transmission size gossipsub will disconnect from the peer being sent the message. This PR updates the logic to simply emit an error, not send the over-sized message but maintain the long-lived streams for future messages. Co-authored-by: Age Manning --- protocols/gossipsub/src/handler.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/protocols/gossipsub/src/handler.rs b/protocols/gossipsub/src/handler.rs index 495bf305..b9cf9559 100644 --- a/protocols/gossipsub/src/handler.rs +++ b/protocols/gossipsub/src/handler.rs @@ -27,7 +27,7 @@ use libp2p_swarm::protocols_handler::{ KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol, }; use libp2p_swarm::NegotiatedSubstream; -use log::{debug, trace, warn}; +use log::{debug, error, trace, warn}; use smallvec::SmallVec; use std::{ borrow::Cow, @@ -274,7 +274,13 @@ impl ProtocolsHandler for GossipsubHandler { Some(OutboundSubstreamState::PendingFlush(substream)) } Err(e) => { - return Poll::Ready(ProtocolsHandlerEvent::Close(e)); + if let io::ErrorKind::PermissionDenied = e.kind() { + error!("Message over the maximum transmission limit was not sent."); + self.outbound_substream = + Some(OutboundSubstreamState::WaitingOutput(substream)); + } else { + return Poll::Ready(ProtocolsHandlerEvent::Close(e)); + } } } }