浏览代码

Merge pull request #14973 from rjl493456442/fix_downloader

eth/downloader: exit loop when there is no more available task
Péter Szilágyi 8 年之前
父节点
当前提交
c8e70186a6
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      eth/downloader/downloader.go

+ 4 - 0
eth/downloader/downloader.go

@@ -1093,6 +1093,10 @@ func (d *Downloader) fetchParts(errCancel error, deliveryCh chan dataPack, deliv
 					throttled = true
 					throttled = true
 					break
 					break
 				}
 				}
+				// Short circuit if there is no more available task.
+				if pending() == 0 {
+					break
+				}
 				// Reserve a chunk of fetches for a peer. A nil can mean either that
 				// Reserve a chunk of fetches for a peer. A nil can mean either that
 				// no more headers are available, or that the peer is known not to
 				// no more headers are available, or that the peer is known not to
 				// have them.
 				// have them.