fix: piece下载死锁

This commit is contained in:
liwei committed 2020-02-28 19:05:01 +08:00
1 parent ee4ff7dd8b
commit b0bd2a776a
2 files changed
+2 -2

No files matched your search

+2
View File
@@ -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
}
-2
View File
@@ -2,7 +2,6 @@ package torrent
import (
"errors"
"fmt"
"github.com/monkeyWie/gopeed/protocol/bt/metainfo"
log "github.com/sirupsen/logrus"
"time"
@@ -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