From d8f29cf69443d6ebe0591b94e1be92cb19145b39 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Wed, 13 Feb 2019 09:47:35 +0100 Subject: [PATCH] swarm/storage: fix LDBStore.batchesC data race by not closing it --- swarm/storage/ldbstore.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index a3c09782ee..f98809fc6c 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -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,9 +1049,6 @@ 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() }