From 09d4f0795aaa69075d28d8e8b39b32733842bbde Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Tue, 3 Jan 2017 17:10:15 -0800 Subject: [PATCH] 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. --- client/client.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/client.go b/client/client.go index d4b5b7f16..45e95e270 100644 --- a/client/client.go +++ b/client/client.go @@ -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