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 <Age@AgeManning.com>
This commit is contained in:
Max Inden 2020-04-28 16:18:35 +02:00 committed by GitHub
parent 3d4ae5da4b
commit 1be34fd7a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));
}
}
}
}