Skip to content

Commit

Permalink
add node to dagserv under lock
Browse files Browse the repository at this point in the history
Otherwise, we could run a GC between adding and pinning.

License: MIT
Signed-off-by: Steven Allen <[email protected]>
  • Loading branch information
Stebalien committed Dec 4, 2017
1 parent 8e780d2 commit 953b610
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pin/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ func NewPinner(dstore ds.Datastore, serv, internal mdag.DAGService) Pinner {
func (p *pinner) Pin(ctx context.Context, node node.Node, recurse bool) error {
p.lock.Lock()
defer p.lock.Unlock()
c := node.Cid()
c, err := p.dserv.Add(node)
if err != nil {
return err
}

if recurse {
if p.recursePin.Has(c) {
Expand Down

0 comments on commit 953b610

Please sign in to comment.