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

Disconnect on protocol timeout #2212

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/network-libp2p/src/custom_proto/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ where
Ok(Async::Ready(())) => {
deadline.reset(Instant::now() + Duration::from_secs(60));
let event = CustomProtoHandlerOut::ProtocolError {
is_severe: false,
is_severe: true,
error: "Timeout when opening protocol".to_string().into(),
};
return_value = Some(ProtocolsHandlerEvent::Custom(event));
Expand Down
3 changes: 3 additions & 0 deletions core/peerset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use futures::{prelude::*, sync::mpsc};
use libp2p::PeerId;
use parking_lot::Mutex;
use std::sync::Arc;
use log::trace;

pub use serde_json::Value;

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

// Automatically connect back if reserved.
if inner.reserved.contains(peer_id) {
Expand Down