Skip to content

Commit

Permalink
Merge pull request #1507 from mrjana/lb
Browse files Browse the repository at this point in the history
Avoid controller/service lock AB/BA situation
  • Loading branch information
mavenugo committed Oct 14, 2016
2 parents bafbeaf + b8ef8c2 commit 04025f2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion service_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ func newService(name string, id string, ingressPorts []*PortConfig, aliases []st

func (c *controller) cleanupServiceBindings(cleanupNID string) {
var cleanupFuncs []func()

c.Lock()
services := make([]*service, 0, len(c.serviceBindings))
for _, s := range c.serviceBindings {
services = append(services, s)
}
c.Unlock()

for _, s := range services {
s.Lock()
for nid, lb := range s.loadBalancers {
if cleanupNID != "" && nid != cleanupNID {
Expand All @@ -67,7 +74,6 @@ func (c *controller) cleanupServiceBindings(cleanupNID string) {
}
s.Unlock()
}
c.Unlock()

for _, f := range cleanupFuncs {
f()
Expand Down

0 comments on commit 04025f2

Please sign in to comment.