Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 9cb1dfb

Browse files
arkparcmichi
authored andcommitted
Disconnect on protocol timeout (#2212)
1 parent dea24cc commit 9cb1dfb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

core/network-libp2p/src/custom_proto/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ where
506506
Ok(Async::Ready(())) => {
507507
deadline.reset(Instant::now() + Duration::from_secs(60));
508508
let event = CustomProtoHandlerOut::ProtocolError {
509-
is_severe: false,
509+
is_severe: true,
510510
error: "Timeout when opening protocol".to_string().into(),
511511
};
512512
return_value = Some(ProtocolsHandlerEvent::Custom(event));

core/peerset/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use futures::{prelude::*, sync::mpsc};
2222
use libp2p::PeerId;
2323
use parking_lot::Mutex;
2424
use std::sync::Arc;
25+
use log::trace;
2526

2627
pub use serde_json::Value;
2728

@@ -238,6 +239,7 @@ impl PeersetMut {
238239
/// peerset is already connected to, in which case it must not answer.
239240
pub fn incoming(&self, peer_id: PeerId, index: IncomingIndex) {
240241
let mut inner = self.parent.inner.lock();
242+
trace!("Incoming {}\nin_slots={:?}\nout_slots={:?}", peer_id, inner.in_slots, inner.out_slots);
241243
if inner.out_slots.iter().chain(inner.in_slots.iter()).any(|s| s.as_ref() == Some(&peer_id)) {
242244
return
243245
}
@@ -260,6 +262,7 @@ impl PeersetMut {
260262
pub fn dropped(&self, peer_id: &PeerId) {
261263
let mut inner = self.parent.inner.lock();
262264
let inner = &mut *inner; // Fixes a borrowing issue.
265+
trace!("Dropping {}\nin_slots={:?}\nout_slots={:?}", peer_id, inner.in_slots, inner.out_slots);
263266

264267
// Automatically connect back if reserved.
265268
if inner.reserved.contains(peer_id) {

0 commit comments

Comments
 (0)