From b0ea0b4d7dd32fbc4d49a0d9348066a1e60c409e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 12 Jun 2019 13:26:49 -0700 Subject: [PATCH] Merge pull request #6444 from dirkmc/fix/pin-rm-add-lock Fix: ensure pin rm takes a lock --- core/coreapi/pin.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index bd2663f03..b8c84da52 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -67,6 +67,10 @@ func (api *PinAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.PinRmOpti return err } + // Note: after unpin the pin sets are flushed to the blockstore, so we need + // to take a lock to prevent a concurrent garbage collection + defer api.blockstore.PinLock().Unlock() + if err = api.pinning.Unpin(ctx, rp.Cid(), settings.Recursive); err != nil { return err }