Do not prematurely emit CustomProtocolClosed on connection close. (#5595)

This commit is contained in:
Roman Borschel
2020-04-09 12:41:34 +02:00
committed by GitHub
parent 7da995214e
commit 40c56deea3
@@ -914,7 +914,7 @@ impl NetworkBehaviour for GenericProto {
// in which case `CustomProtocolClosed` was already emitted.
let closed = open.is_empty();
open.retain(|c| c != conn);
if !closed {
if open.is_empty() && !closed {
debug!(target: "sub-libp2p", "External API <= Closed({})", peer_id);
let event = GenericProtoOut::CustomProtocolClosed {
peer_id: peer_id.clone(),