downloader/queue: fix remaining lock flaw

This commit is contained in:
Martin Holst Swende 2020-01-29 13:33:05 +01:00
parent 2b5da62940
commit 060e2c02bb
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -847,7 +847,6 @@ func (q *queue) deliver(id string, taskPool map[common.Hash]*types.Header,
i++ i++
} }
q.lock.Lock()
var acceptCount = 0 var acceptCount = 0
for _, header := range request.Headers[:i] { for _, header := range request.Headers[:i] {
if res, stale, err := q.resultCache.GetDeliverySlot(header.Number.Uint64()); err == nil { if res, stale, err := q.resultCache.GetDeliverySlot(header.Number.Uint64()); err == nil {
@ -871,7 +870,6 @@ func (q *queue) deliver(id string, taskPool map[common.Hash]*types.Header,
if acceptCount > 0 { if acceptCount > 0 {
q.active.Signal() q.active.Signal()
} }
q.lock.Unlock()
// If none of the data was good, it's a stale delivery // If none of the data was good, it's a stale delivery
switch { switch {
case failure == nil || failure == errInvalidChain: case failure == nil || failure == errInvalidChain: