mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Avoid controller/service lock AB/BA situation
Currently there is an instance of controller and service lock being obtained in different order which causes the AB/BA deadlock. Do not ever wrap controller lock around service lock. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
parent
ab217f0ea9
commit
e18c1ffd0c
1 changed files with 7 additions and 1 deletions
|
@ -41,8 +41,15 @@ func newService(name string, id string, ingressPorts []*PortConfig, aliases []st
|
||||||
|
|
||||||
func (c *controller) cleanupServiceBindings(cleanupNID string) {
|
func (c *controller) cleanupServiceBindings(cleanupNID string) {
|
||||||
var cleanupFuncs []func()
|
var cleanupFuncs []func()
|
||||||
|
|
||||||
c.Lock()
|
c.Lock()
|
||||||
|
services := make([]*service, 0, len(c.serviceBindings))
|
||||||
for _, s := range c.serviceBindings {
|
for _, s := range c.serviceBindings {
|
||||||
|
services = append(services, s)
|
||||||
|
}
|
||||||
|
c.Unlock()
|
||||||
|
|
||||||
|
for _, s := range services {
|
||||||
s.Lock()
|
s.Lock()
|
||||||
for nid, lb := range s.loadBalancers {
|
for nid, lb := range s.loadBalancers {
|
||||||
if cleanupNID != "" && nid != cleanupNID {
|
if cleanupNID != "" && nid != cleanupNID {
|
||||||
|
@ -67,7 +74,6 @@ func (c *controller) cleanupServiceBindings(cleanupNID string) {
|
||||||
}
|
}
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
}
|
}
|
||||||
c.Unlock()
|
|
||||||
|
|
||||||
for _, f := range cleanupFuncs {
|
for _, f := range cleanupFuncs {
|
||||||
f()
|
f()
|
||||||
|
|
Loading…
Add table
Reference in a new issue