From 486f01353905629a1d03b4231e7062e13d80804d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 6 Jun 2019 15:42:03 -0700 Subject: [PATCH] pin: fix concurrent map access race Not sure why this didn't show up sooner. fixes #6418 --- pin/pin.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pin/pin.go b/pin/pin.go index 8df21ee1ce3..48a16f84e5e 100644 --- a/pin/pin.go +++ b/pin/pin.go @@ -498,11 +498,17 @@ func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error) // DirectKeys returns a slice containing the directly pinned keys func (p *pinner) DirectKeys() []cid.Cid { + p.lock.RLock() + defer p.lock.RUnlock() + return p.directPin.Keys() } // RecursiveKeys returns a slice containing the recursively pinned keys func (p *pinner) RecursiveKeys() []cid.Cid { + p.lock.RLock() + defer p.lock.RUnlock() + return p.recursePin.Keys() }