Skip to content

Commit fabb016

Browse files
authored
Merge pull request moby#51966 from corhere/getlbindex-fix-race
d/libnetwork: fix (*Controller).getLBIndex panic
2 parents 127a647 + 21dd960 commit fabb016

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

daemon/libnetwork/service_common.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,14 @@ func (c *Controller) getLBIndex(sid, nid string, ingressPorts []*PortConfig) int
160160
}
161161

162162
s.Lock()
163+
defer s.Unlock()
164+
if s.deleted {
165+
return 0
166+
}
163167
lb := s.loadBalancers[nid]
164-
s.Unlock()
165-
168+
if lb == nil {
169+
return 0
170+
}
166171
return int(lb.fwMark)
167172
}
168173

0 commit comments

Comments
 (0)