Fix race in setting plugin refcounts.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: 4c088d1e2ebfcc384a365734017988f4fd1c4605
Component: engine
This commit is contained in:
Anusha Ragunathan
2016-12-09 09:34:30 -08:00
parent ae7e2b46cd
commit 955998db83
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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)
}
+3 -3
View File
@@ -278,12 +278,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.