mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
swarm/storage: Eliminate potential duplicate gc under lock
This commit is contained in:
parent
2bfa37cdb3
commit
916a3e196e
1 changed files with 4 additions and 2 deletions
|
|
@ -314,10 +314,12 @@ func decodeData(addr Address, data []byte) (*chunk, error) {
|
|||
func (s *LDBStore) collectGarbage() error {
|
||||
|
||||
// prevent duplicate gc from starting when one is already running
|
||||
if len(s.gc.runC) == 0 {
|
||||
select {
|
||||
case <-s.gc.runC:
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
<-s.gc.runC
|
||||
|
||||
s.lock.Lock()
|
||||
entryCnt := s.entryCnt
|
||||
s.lock.Unlock()
|
||||
|
|
|
|||
Loading…
Reference in a new issue