Skip to content

Commit

Permalink
fix: piece下载死锁
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Feb 28, 2020
1 parent ee4ff7d commit b0bd2a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 2 additions & 0 deletions protocol/bt/torrent/peer_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func (pc *peerConn) downloadPiece(index int) error {
select {
case pc.blockQueueCh <- nil:
break
case err := <-pc.downloadedCh:
return err
case err := <-pc.disconnectCh:
return err
}
Expand Down
2 changes: 0 additions & 2 deletions protocol/bt/torrent/torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package torrent

import (
"errors"
"fmt"
"github.com/monkeyWie/gopeed/protocol/bt/metainfo"
log "github.com/sirupsen/logrus"
"time"
Expand Down Expand Up @@ -43,7 +42,6 @@ func (t *Torrent) Download(path string) {
index := t.pieces.getReady()
// 没有待下载的piece了
if index == -1 {
fmt.Println("wait piece")
if <-t.completeCh {
// 下载完成
break
Expand Down

0 comments on commit b0bd2a7

Please sign in to comment.