pin: fix concurrent map access race
Not sure why this didn't show up sooner. fixes #6418
Steven Allen committed
Jun 6, 2019 at 15:42 UTC
486f01353905629a1d03b4231e7062e13d80804d
1 file changed
+6
pin/pin.go
+6
@@ -498,11 +498,17 @@ func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error)
498
499
// DirectKeys returns a slice containing the directly pinned keys
500
func (p *pinner) DirectKeys() []cid.Cid {
501
+ p.lock.RLock()
502
+ defer p.lock.RUnlock()
503
+
504
return p.directPin.Keys()
505
}
506
507
// RecursiveKeys returns a slice containing the recursively pinned keys
508
func (p *pinner) RecursiveKeys() []cid.Cid {
509
+ p.lock.RLock()
510
+ defer p.lock.RUnlock()
511
+
512
return p.recursePin.Keys()
513
}
514