Skip to content

Commit 5030853

Browse files
committed
ech
Signed-off-by: VihasMakwana <121151420+VihasMakwana@users.noreply.github.com>
1 parent b0c50f2 commit 5030853

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

db.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,18 +1254,16 @@ func (db *DB) freepages() []common.Pgid {
12541254
nofreed := make(map[common.Pgid]bool)
12551255
ech := make(chan error)
12561256

1257-
var wg sync.WaitGroup
1258-
1259-
wg.Add(1)
12601257
go func() {
1261-
defer wg.Done()
1258+
defer close(ech)
12621259
tx.recursivelyCheckBucket(&tx.root, reachable, nofreed, HexKVStringer(), ech)
1263-
close(ech)
12641260
}()
1261+
// following for loop will exit once channel is closed in the above goroutine.
1262+
// we don't need to wait explictly with a waitgroup
12651263
for e := range ech {
12661264
panic(fmt.Sprintf("freepages: failed to get all reachable pages (%v)", e))
12671265
}
1268-
wg.Wait()
1266+
12691267
// TODO: If check bucket reported any corruptions (ech) we shouldn't proceed to freeing the pages.
12701268

12711269
var fids []common.Pgid

0 commit comments

Comments
 (0)