Fix race in setting plugin refcounts.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
(cherry picked from commit 4c088d1e2e
)
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
3a571b72fd
commit
1c858abc96
|
@ -174,7 +174,7 @@ func (ps *Store) Get(name, capability string, mode int) (plugingetter.CompatPlug
|
||||||
}
|
}
|
||||||
p, err = ps.GetByName(fullName)
|
p, err = ps.GetByName(fullName)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
p.SetRefCount(mode + p.GetRefCount())
|
p.AddRefCount(mode)
|
||||||
if p.IsEnabled() {
|
if p.IsEnabled() {
|
||||||
return p.FilterByCap(capability)
|
return p.FilterByCap(capability)
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,12 +286,12 @@ func (p *Plugin) GetRefCount() int {
|
||||||
return p.refCount
|
return p.refCount
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRefCount sets the reference count.
|
// AddRefCount adds to reference count.
|
||||||
func (p *Plugin) SetRefCount(count int) {
|
func (p *Plugin) AddRefCount(count int) {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
defer p.mu.Unlock()
|
||||||
|
|
||||||
p.refCount = count
|
p.refCount += count
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitSpec creates an OCI spec from the plugin's config.
|
// InitSpec creates an OCI spec from the plugin's config.
|
||||||
|
|
Loading…
Reference in New Issue