Skip to content

Commit

Permalink
improve peer closing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Jun 27, 2023
1 parent 742c1b8 commit 3eb8953
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func (p *Peer) Close() {
p.downloadSpeed.Stop()
p.uploadSpeed.Stop()
<-p.doneC
p.Closed = true
}

// Done returns a channel that is closed when a peers run loop is ended.
Expand Down
4 changes: 4 additions & 0 deletions torrent/torrent_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ func (t *torrent) close() {
}

func (t *torrent) closePeer(pe *peer.Peer) {
if pe.Closed {
return
}
pe.Close()
pe.Closed = true
if pd, ok := t.pieceDownloaders[pe]; ok {
t.closePieceDownloader(pd)
}
Expand Down

0 comments on commit 3eb8953

Please sign in to comment.