Avoid double close of agentInitDone

Avoid by reinitializing the channel immediately after closing the
channel within a lock. Also change the wait code to cache the channel in
stack be retrieving it from controller and wait on the stack copy of the
channel.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
Jana Radhakrishnan 2016-08-24 09:51:02 -07:00
parent 301e41aff7
commit b29ba21551
2 changed files with 11 additions and 2 deletions

View File

@ -193,9 +193,12 @@ func (c *controller) agentSetup() error {
}
}
if c.agent != nil {
c.Lock()
if c.agent != nil && c.agentInitDone != nil {
close(c.agentInitDone)
c.agentInitDone = nil
}
c.Unlock()
return nil
}

View File

@ -347,7 +347,13 @@ func (c *controller) clusterAgentInit() {
// AgentInitWait waits for agent initialization to be completed in the
// controller.
func (c *controller) AgentInitWait() {
<-c.agentInitDone
c.Lock()
agentInitDone := c.agentInitDone
c.Unlock()
if agentInitDone != nil {
<-agentInitDone
}
}
func (c *controller) makeDriverConfig(ntype string) map[string]interface{} {