From 6d12227f3518594150ee90ac67cef5cdb5e44b60 Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Mon, 20 Nov 2023 16:03:07 +0000 Subject: [PATCH] wanted to match on network unreachable, but it turns out its unstable --- crates/librqbit/src/torrent_state.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/librqbit/src/torrent_state.rs b/crates/librqbit/src/torrent_state.rs index 61ed206..34f672c 100644 --- a/crates/librqbit/src/torrent_state.rs +++ b/crates/librqbit/src/torrent_state.rs @@ -866,13 +866,16 @@ impl PeerHandler { } }; - if error.is_none() { - debug!("peer died without errors, not re-queueing"); - pe.value_mut().state.set(PeerState::NotNeeded, pstats); - return; - } else { - self.counters.errors.fetch_add(1, Ordering::Relaxed); - } + let _error = match error { + Some(e) => e, + None => { + debug!("peer died without errors, not re-queueing"); + pe.value_mut().state.set(PeerState::NotNeeded, pstats); + return; + } + }; + + self.counters.errors.fetch_add(1, Ordering::Relaxed); if self.state.is_finished() { debug!("torrent finished, not re-queueing"); @@ -881,6 +884,7 @@ impl PeerHandler { } pe.value_mut().state.set(PeerState::Dead, pstats); + let backoff = pe.value_mut().stats.backoff.next_backoff(); // Prevent deadlocks.