From a98ead38faa9943e0e7937cd7605fab2218e55ff Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Wed, 10 Apr 2019 18:09:26 +0000 Subject: [PATCH] [crash] fix issue #703 Signed-off-by: Leo Chen --- api/service/syncing/syncing.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/service/syncing/syncing.go b/api/service/syncing/syncing.go index ba9086fe3..6bcb2e5d8 100644 --- a/api/service/syncing/syncing.go +++ b/api/service/syncing/syncing.go @@ -343,14 +343,14 @@ func (ss *StateSync) downloadBlocks(bc *core.BlockChain) { defer wg.Done() for !stateSyncTaskQueue.Empty() { task, err := ss.stateSyncTaskQueue.Poll(1, time.Millisecond) - if err == queue.ErrTimeout { + if err == queue.ErrTimeout || len(task) == 0 { utils.GetLogInstance().Debug("[SYNC] ss.stateSyncTaskQueue poll timeout", "error", err) break } syncTask := task[0].(SyncBlockTask) //id := syncTask.index payload, err := peerConfig.GetBlocks([][]byte{syncTask.blockHash}) - if err != nil { + if err != nil || len(payload) == 0 { count++ utils.GetLogInstance().Debug("[SYNC] GetBlocks failed", "failNumber", count) if count > TimesToFail {