mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #42569 from steffengy/master-2
libnetwork: processEndpointCreate: Fix deadlock between getSvcRecords and processEndpointCreate
This commit is contained in:
commit
2a562b1583
1 changed files with 8 additions and 5 deletions
|
@ -340,8 +340,11 @@ func (c *controller) processEndpointCreate(nmap map[string]*netWatch, ep *endpoi
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkID := n.ID()
|
||||||
|
endpointID := ep.ID()
|
||||||
|
|
||||||
c.Lock()
|
c.Lock()
|
||||||
nw, ok := nmap[n.ID()]
|
nw, ok := nmap[networkID]
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -349,12 +352,12 @@ func (c *controller) processEndpointCreate(nmap map[string]*netWatch, ep *endpoi
|
||||||
n.updateSvcRecord(ep, c.getLocalEps(nw), true)
|
n.updateSvcRecord(ep, c.getLocalEps(nw), true)
|
||||||
|
|
||||||
c.Lock()
|
c.Lock()
|
||||||
nw.localEps[ep.ID()] = ep
|
nw.localEps[endpointID] = ep
|
||||||
|
|
||||||
// If we had learned that from the kv store remove it
|
// If we had learned that from the kv store remove it
|
||||||
// from remote ep list now that we know that this is
|
// from remote ep list now that we know that this is
|
||||||
// indeed a local endpoint
|
// indeed a local endpoint
|
||||||
delete(nw.remoteEps, ep.ID())
|
delete(nw.remoteEps, endpointID)
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -370,8 +373,8 @@ func (c *controller) processEndpointCreate(nmap map[string]*netWatch, ep *endpoi
|
||||||
n.updateSvcRecord(ep, c.getLocalEps(nw), true)
|
n.updateSvcRecord(ep, c.getLocalEps(nw), true)
|
||||||
|
|
||||||
c.Lock()
|
c.Lock()
|
||||||
nw.localEps[ep.ID()] = ep
|
nw.localEps[endpointID] = ep
|
||||||
nmap[n.ID()] = nw
|
nmap[networkID] = nw
|
||||||
nw.stopCh = make(chan struct{})
|
nw.stopCh = make(chan struct{})
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue