Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
swarm/storage/localstore: lock item address in collectGarbage iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Dec 21, 2018
1 parent 5edd22d commit 95726d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions swarm/storage/localstore/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ func (db *DB) collectGarbage() (collectedCount int64, done bool, err error) {

done = true
err = db.gcIndex.Iterate(func(item shed.Item) (stop bool, err error) {
// protect parallel updates
unlock, err := db.lockAddr(item.Address)
if err != nil {
return false, err
}
defer unlock()

gcSize := atomic.LoadInt64(&db.gcSize)
if gcSize-collectedCount <= target {
return true, nil
Expand Down

0 comments on commit 95726d7

Please sign in to comment.