Fix race when shutting down in dev mode

Client.Shutdown holds the allocLock when destroying alloc runners in dev
mode.

Client.updateAllocStatus can be called during AllocRunner shutdown and
calls getAllocRunners which tries to acquire allocLock.RLock. This
deadlocks since Client.Shutdown already has the write lock.

Switching Client.Shutdown to use getAllocRunners and not hold a lock
during AllocRunner shutdown is the solution.
This commit is contained in:
Michael Schurter 2017-01-03 17:10:15 -08:00
parent b4bf33b95a
commit 13064768ac
1 changed files with 1 additions and 3 deletions

View File

@ -378,12 +378,10 @@ func (c *Client) Shutdown() error {
// Destroy all the running allocations.
if c.config.DevMode {
c.allocLock.Lock()
for _, ar := range c.allocs {
for _, ar := range c.getAllocRunners() {
ar.Destroy()
<-ar.WaitCh()
}
c.allocLock.Unlock()
}
c.shutdown = true