mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/storage/localstore: lock item address in collectGarbage iterator
This commit is contained in:
parent
5edd22d075
commit
95726d73d6
1 changed files with 7 additions and 0 deletions
|
|
@ -79,6 +79,13 @@ func (db *DB) collectGarbage() (collectedCount int64, done bool, err error) {
|
||||||
|
|
||||||
done = true
|
done = true
|
||||||
err = db.gcIndex.Iterate(func(item shed.Item) (stop bool, err error) {
|
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)
|
gcSize := atomic.LoadInt64(&db.gcSize)
|
||||||
if gcSize-collectedCount <= target {
|
if gcSize-collectedCount <= target {
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue