Skip to content

Commit

Permalink
Merge pull request #6281 from ipfs/fix/6279
Browse files Browse the repository at this point in the history
gc: cancel context
  • Loading branch information
Stebalien authored Apr 30, 2019
2 parents 832077b + 223cae0 commit 6474452
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions core/corerepo/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ func BestEffortRoots(filesRoot *mfs.Root) ([]cid.Cid, error) {
}

func GarbageCollect(n *core.IpfsNode, ctx context.Context) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel() // in case error occurs during operation
roots, err := BestEffortRoots(n.FilesRoot)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pin/gc/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Result struct {
// The routine then iterates over every block in the blockstore and
// 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 {
ctx, cancel := context.WithCancel(ctx)

elock := log.EventBegin(ctx, "GC.lockWait")
unlocker := bs.GCLock()
Expand All @@ -52,6 +53,7 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn
output := make(chan Result, 128)

go func() {
defer cancel()
defer close(output)
defer unlocker.Unlock()
defer elock.Done()
Expand Down

0 comments on commit 6474452

Please sign in to comment.