eth/downloader: fix mutex regression causing panics on fail

This commit is contained in:
Péter Szilágyi 2017-01-19 11:18:12 +02:00
parent f087c66f95
commit b0ec4359a5
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D

View file

@ -1129,12 +1129,13 @@ func (q *queue) deliverNodeData(results []trie.SyncResult, callback func(int, bo
if err != nil { if err != nil {
q.stateSchedLock.Unlock() q.stateSchedLock.Unlock()
callback(i, progressed, err) callback(i, progressed, err)
return
} }
if err = batch.Write(); err != nil { if err = batch.Write(); err != nil {
q.stateSchedLock.Unlock() q.stateSchedLock.Unlock()
callback(i, progressed, err) callback(i, progressed, err)
return // TODO(karalabe): If a DB write fails (disk full), we ought to cancel the sync
} }
// Item processing succeeded, release the lock (temporarily) // Item processing succeeded, release the lock (temporarily)
progressed = progressed || prog progressed = progressed || prog
q.stateSchedLock.Unlock() q.stateSchedLock.Unlock()