diff --git a/plugin/store/store.go b/plugin/store/store.go index 4f4665eb42..81e89581cc 100644 --- a/plugin/store/store.go +++ b/plugin/store/store.go @@ -174,7 +174,7 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug } p, err = ps.GetByName(fullName) if err == nil { - p.SetRefCount(mode + p.GetRefCount()) + p.AddRefCount(mode) if p.IsEnabled() { return p.FilterByCap(capability) } diff --git a/plugin/v2/plugin.go b/plugin/v2/plugin.go index be4a87d05f..ff8f5ff235 100644 --- a/plugin/v2/plugin.go +++ b/plugin/v2/plugin.go @@ -286,12 +286,12 @@ func (p *Plugin) GetRefCount() int { return p.refCount } -// SetRefCount sets the reference count. -func (p *Plugin) SetRefCount(count int) { +// AddRefCount adds to reference count. +func (p *Plugin) AddRefCount(count int) { p.mu.Lock() defer p.mu.Unlock() - p.refCount = count + p.refCount += count } // InitSpec creates an OCI spec from the plugin's config.