mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 19:02:13 +00:00
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:
parent
3d4ae5da4b
commit
1be34fd7a3
@ -27,7 +27,7 @@ use libp2p_swarm::protocols_handler::{
|
|||||||
KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol,
|
KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol,
|
||||||
};
|
};
|
||||||
use libp2p_swarm::NegotiatedSubstream;
|
use libp2p_swarm::NegotiatedSubstream;
|
||||||
use log::{debug, trace, warn};
|
use log::{debug, error, trace, warn};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
@ -274,10 +274,16 @@ impl ProtocolsHandler for GossipsubHandler {
|
|||||||
Some(OutboundSubstreamState::PendingFlush(substream))
|
Some(OutboundSubstreamState::PendingFlush(substream))
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(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));
|
return Poll::Ready(ProtocolsHandlerEvent::Close(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Poll::Ready(Err(e)) => {
|
Poll::Ready(Err(e)) => {
|
||||||
debug!("Outbound substream error while sending output: {:?}", e);
|
debug!("Outbound substream error while sending output: {:?}", e);
|
||||||
return Poll::Ready(ProtocolsHandlerEvent::Close(e));
|
return Poll::Ready(ProtocolsHandlerEvent::Close(e));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user