mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
swarm/storage: fix LDBStore.batchesC data race by not closing it
This commit is contained in:
parent
714d871faa
commit
d8f29cf694
1 changed files with 1 additions and 4 deletions
|
|
@ -805,12 +805,12 @@ func (s *LDBStore) Put(ctx context.Context, chunk Chunk) error {
|
||||||
gcIdxKey := getGCIdxKey(&index)
|
gcIdxKey := getGCIdxKey(&index)
|
||||||
gcIdxData := getGCIdxValue(&index, po, chunk.Address())
|
gcIdxData := getGCIdxValue(&index, po, chunk.Address())
|
||||||
s.batch.Put(gcIdxKey, gcIdxData)
|
s.batch.Put(gcIdxKey, gcIdxData)
|
||||||
|
s.lock.Unlock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case s.batchesC <- struct{}{}:
|
case s.batchesC <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
s.lock.Unlock()
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-batch.c:
|
case <-batch.c:
|
||||||
|
|
@ -1049,9 +1049,6 @@ func (s *LDBStore) Close() {
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
// force writing out current batch
|
// force writing out current batch
|
||||||
s.writeCurrentBatch()
|
s.writeCurrentBatch()
|
||||||
s.lock.Lock()
|
|
||||||
close(s.batchesC)
|
|
||||||
s.lock.Unlock()
|
|
||||||
s.db.Close()
|
s.db.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue