Removed a couple deadlocks

This commit is contained in:
Igor Katson 2023-11-19 16:25:59 +00:00
parent 38c99023ac
commit adf3eef877
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
7 changed files with 899 additions and 1 deletions

View file

@ -543,6 +543,8 @@ impl TorrentState {
}
PeerState::Queued | PeerState::Dead | PeerState::NotNeeded => {
warn!("bug: peer was in a wrong state, ignoring it forever");
// Prevent deadlocks.
drop(pe);
self.peers.drop_peer(handle);
return;
}
@ -563,6 +565,9 @@ impl TorrentState {
pe.value_mut().state = PeerState::Dead;
let backoff = pe.value_mut().stats.backoff.next_backoff();
// Prevent deadlocks.
drop(pe);
if let Some(dur) = backoff {
let state = self.clone();
spawn(