Commit 8fd81260 authored by Steven Allen's avatar Steven Allen

gc: cancel context

We were canceling the context in `GarbageCollect` but some functions call `GC`
directly. Move the context cancelation down to where we actually _need_ it.

fixes #6279

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent 1aabde8d
...@@ -39,6 +39,7 @@ type Result struct { ...@@ -39,6 +39,7 @@ type Result struct {
// The routine then iterates over every block in the blockstore and // The routine then iterates over every block in the blockstore and
// deletes any block that is not found in the marked set. // deletes any block that is not found in the marked set.
func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn pin.Pinner, bestEffortRoots []cid.Cid) <-chan Result { func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn pin.Pinner, bestEffortRoots []cid.Cid) <-chan Result {
ctx, cancel := context.WithCancel(ctx)
elock := log.EventBegin(ctx, "GC.lockWait") elock := log.EventBegin(ctx, "GC.lockWait")
unlocker := bs.GCLock() unlocker := bs.GCLock()
...@@ -52,6 +53,7 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn ...@@ -52,6 +53,7 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
output := make(chan Result, 128) output := make(chan Result, 128)
go func() { go func() {
defer cancel()
defer close(output) defer close(output)
defer unlocker.Unlock() defer unlocker.Unlock()
defer elock.Done() defer elock.Done()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment