Skip to content
Snippets Groups Projects
Commit 8d81a8b8 authored by Jeromy Johnson's avatar Jeromy Johnson
Browse files

fix locking in the pinner

parent 8fa9252f
No related branches found
No related tags found
1 merge request!1New
......@@ -200,6 +200,8 @@ func (p *pinner) IsPinned(key util.Key) bool {
}
func (p *pinner) RemovePinWithMode(key util.Key, mode PinMode) {
p.lock.Lock()
defer p.lock.Unlock()
switch mode {
case Direct:
p.directPin.RemoveBlock(key)
......@@ -265,8 +267,8 @@ func (p *pinner) RecursiveKeys() []util.Key {
// Flush encodes and writes pinner keysets to the datastore
func (p *pinner) Flush() error {
p.lock.RLock()
defer p.lock.RUnlock()
p.lock.Lock()
defer p.lock.Unlock()
err := storeSet(p.dstore, directPinDatastoreKey, p.directPin.GetKeys())
if err != nil {
......@@ -311,6 +313,8 @@ func loadSet(d ds.Datastore, k ds.Key, val interface{}) error {
// PinWithMode is a method on ManualPinners, allowing the user to have fine
// grained control over pin counts
func (p *pinner) PinWithMode(k util.Key, mode PinMode) {
p.lock.Lock()
defer p.lock.Unlock()
switch mode {
case Recursive:
p.recursePin.AddBlock(k)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment