Browse Source

Prevent race in PersistableChannelUniqueQueue.Has (#14651)

There is potentially a race with a slow starting internal
queue causing a NPE if Has is checked before the internal
queue has been setup.

This PR adds a lock on the Has() fn.

Fix #14311

Signed-off-by: Andrew Thornton <art27@cantab.net>
tags/v1.15.0-dev
zeripath 3 years ago
parent
commit
b3c2e23cbb
No account linked to committer's email address
1 changed files with 5 additions and 0 deletions
  1. 5
    0
      modules/queue/unique_queue_disk_channel.go

+ 5
- 0
modules/queue/unique_queue_disk_channel.go View File

@@ -149,6 +149,11 @@ func (q *PersistableChannelUniqueQueue) Has(data Data) (bool, error) {
if err != nil || has {
return has, err
}
q.lock.Lock()
defer q.lock.Unlock()
if q.internal == nil {
return false, nil
}
return q.internal.(UniqueQueue).Has(data)
}


Loading…
Cancel
Save