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