Merge pull request #6419 from ipfs/fix/6418
pin: fix concurrent map access race
Steven Allen committed
Jun 6, 2019 at 15:50 UTC
7c777eb83b7b474c6f697dafbbb20cad8a8801c2
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