diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2019-03-05 05:19:57 +0800 |
---|---|---|
committer | Viktor Trón <viktor.tron@gmail.com> | 2019-03-05 05:19:57 +0800 |
commit | 216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf (patch) | |
tree | b41f06a489726305ac900f069eecd94a383cda49 /swarm/storage | |
parent | a1099bb7e91899bbcfb615cd229ca422fc68605b (diff) | |
download | go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.tar go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.tar.gz go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.tar.bz2 go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.tar.lz go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.tar.xz go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.tar.zst go-tangerine-216bd2ceba2eb1708b7bdc7d69cf2984ff972cbf.zip |
swarm/storage/localstore: fix testDB_collectGarbageWorker data race (#19206)
Diffstat (limited to 'swarm/storage')
-rw-r--r-- | swarm/storage/localstore/gc_test.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/swarm/storage/localstore/gc_test.go b/swarm/storage/localstore/gc_test.go index 3964c16d5..c2ad774d3 100644 --- a/swarm/storage/localstore/gc_test.go +++ b/swarm/storage/localstore/gc_test.go @@ -51,14 +51,16 @@ func testDB_collectGarbageWorker(t *testing.T) { chunkCount := 150 - testHookCollectGarbageChan := make(chan int64) - defer setTestHookCollectGarbage(func(collectedCount int64) { - testHookCollectGarbageChan <- collectedCount - })() - db, cleanupFunc := newTestDB(t, &Options{ Capacity: 100, }) + testHookCollectGarbageChan := make(chan int64) + defer setTestHookCollectGarbage(func(collectedCount int64) { + select { + case testHookCollectGarbageChan <- collectedCount: + case <-db.close: + } + })() defer cleanupFunc() uploader := db.NewPutter(ModePutUpload) |