Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1525 from katarzyna-z/fix-unstoppable-task
Browse files Browse the repository at this point in the history
Fixes #1482, removed unsafe double RLock
  • Loading branch information
PatrykMatyjasek authored Feb 24, 2017
2 parents 80210a4 + 70d5b5e commit 00d1c24
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions control/strategy/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ func (p *pool) RestartCount() int {
}

func (p *pool) IncRestartCount() {
p.RLock()
defer p.RUnlock()
p.Lock()
defer p.Unlock()
p.restartCount++
}

Expand Down Expand Up @@ -261,12 +261,12 @@ func (p *pool) Eligible() bool {

// optimization: don't even bother with concurrency
// count if we have already reached pool max
if p.Count() >= p.max {
if len(p.plugins) >= p.max {
return false
}

// Check if pool is eligible and number of plugins is less than maximum allowed
if p.SubscriptionCount() > p.concurrencyCount*p.Count() {
if len(p.subs) > p.concurrencyCount*len(p.plugins) {
return true
}

Expand Down Expand Up @@ -361,10 +361,8 @@ func (p *pool) SubscriptionCount() int {
}

// SelectAP selects an available plugin from the pool
// the method is not thread safe, it should be protected outside of the body
func (p *pool) SelectAP(taskID string, config map[string]ctypes.ConfigValue) (AvailablePlugin, serror.SnapError) {
p.RLock()
defer p.RUnlock()

aps := p.plugins.Values()

var id string
Expand Down

0 comments on commit 00d1c24

Please sign in to comment.