Skip to content

Commit b5dc370

Browse files
authored
Merge pull request #2633 from optionfactory/master
Enforce order of lock acquisitions on network/controller, fixes #2632
2 parents b350742 + c4ea04e commit b5dc370

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

network.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,21 +1409,21 @@ func (n *network) addSvcRecords(eID, name, serviceID string, epIP, epIPv6 net.IP
14091409
if n.ingress {
14101410
return
14111411
}
1412-
1413-
logrus.Debugf("%s (%.7s).addSvcRecords(%s, %s, %s, %t) %s sid:%s", eID, n.ID(), name, epIP, epIPv6, ipMapUpdate, method, serviceID)
1412+
networkID := n.ID()
1413+
logrus.Debugf("%s (%.7s).addSvcRecords(%s, %s, %s, %t) %s sid:%s", eID, networkID, name, epIP, epIPv6, ipMapUpdate, method, serviceID)
14141414

14151415
c := n.getController()
14161416
c.Lock()
14171417
defer c.Unlock()
14181418

1419-
sr, ok := c.svcRecords[n.ID()]
1419+
sr, ok := c.svcRecords[networkID]
14201420
if !ok {
14211421
sr = svcInfo{
14221422
svcMap: setmatrix.NewSetMatrix(),
14231423
svcIPv6Map: setmatrix.NewSetMatrix(),
14241424
ipMap: setmatrix.NewSetMatrix(),
14251425
}
1426-
c.svcRecords[n.ID()] = sr
1426+
c.svcRecords[networkID] = sr
14271427
}
14281428

14291429
if ipMapUpdate {
@@ -1445,14 +1445,14 @@ func (n *network) deleteSvcRecords(eID, name, serviceID string, epIP net.IP, epI
14451445
if n.ingress {
14461446
return
14471447
}
1448-
1449-
logrus.Debugf("%s (%.7s).deleteSvcRecords(%s, %s, %s, %t) %s sid:%s ", eID, n.ID(), name, epIP, epIPv6, ipMapUpdate, method, serviceID)
1448+
networkID := n.ID()
1449+
logrus.Debugf("%s (%.7s).deleteSvcRecords(%s, %s, %s, %t) %s sid:%s ", eID, networkID, name, epIP, epIPv6, ipMapUpdate, method, serviceID)
14501450

14511451
c := n.getController()
14521452
c.Lock()
14531453
defer c.Unlock()
14541454

1455-
sr, ok := c.svcRecords[n.ID()]
1455+
sr, ok := c.svcRecords[networkID]
14561456
if !ok {
14571457
return
14581458
}
@@ -1972,9 +1972,10 @@ func (n *network) ResolveName(req string, ipType int) ([]net.IP, bool) {
19721972
var ipv6Miss bool
19731973

19741974
c := n.getController()
1975+
networkID := n.ID()
19751976
c.Lock()
19761977
defer c.Unlock()
1977-
sr, ok := c.svcRecords[n.ID()]
1978+
sr, ok := c.svcRecords[networkID]
19781979

19791980
if !ok {
19801981
return nil, false
@@ -2012,10 +2013,11 @@ func (n *network) ResolveName(req string, ipType int) ([]net.IP, bool) {
20122013
}
20132014

20142015
func (n *network) HandleQueryResp(name string, ip net.IP) {
2016+
networkID := n.ID()
20152017
c := n.getController()
20162018
c.Lock()
20172019
defer c.Unlock()
2018-
sr, ok := c.svcRecords[n.ID()]
2020+
sr, ok := c.svcRecords[networkID]
20192021

20202022
if !ok {
20212023
return
@@ -2031,10 +2033,11 @@ func (n *network) HandleQueryResp(name string, ip net.IP) {
20312033
}
20322034

20332035
func (n *network) ResolveIP(ip string) string {
2036+
networkID := n.ID()
20342037
c := n.getController()
20352038
c.Lock()
20362039
defer c.Unlock()
2037-
sr, ok := c.svcRecords[n.ID()]
2040+
sr, ok := c.svcRecords[networkID]
20382041

20392042
if !ok {
20402043
return ""
@@ -2085,9 +2088,10 @@ func (n *network) ResolveService(name string) ([]*net.SRV, []net.IP) {
20852088
proto := parts[1]
20862089
svcName := strings.Join(parts[2:], ".")
20872090

2091+
networkID := n.ID()
20882092
c.Lock()
20892093
defer c.Unlock()
2090-
sr, ok := c.svcRecords[n.ID()]
2094+
sr, ok := c.svcRecords[networkID]
20912095

20922096
if !ok {
20932097
return nil, nil

0 commit comments

Comments
 (0)