mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1338 from vladqa/mutex-svc-records
added mutex on read from controller.svcRecords map
This commit is contained in:
commit
5a38961bc9
2 changed files with 22 additions and 4 deletions
|
@ -1105,9 +1105,13 @@ func (n *network) getSvcRecords(ep *endpoint) []etchosts.Record {
|
|||
}
|
||||
|
||||
var recs []etchosts.Record
|
||||
sr, _ := n.ctrlr.svcRecords[n.id]
|
||||
|
||||
epName := ep.Name()
|
||||
|
||||
n.ctrlr.Lock()
|
||||
sr, _ := n.ctrlr.svcRecords[n.id]
|
||||
n.ctrlr.Unlock()
|
||||
|
||||
for h, ip := range sr.svcMap {
|
||||
if strings.Split(h, ".")[0] == epName {
|
||||
continue
|
||||
|
|
|
@ -413,7 +413,12 @@ func (sb *sandbox) ResolveIP(ip string) string {
|
|||
for _, ep := range sb.getConnectedEndpoints() {
|
||||
n := ep.getNetwork()
|
||||
|
||||
sr, ok := n.getController().svcRecords[n.ID()]
|
||||
c := n.getController()
|
||||
|
||||
c.Lock()
|
||||
sr, ok := c.svcRecords[n.ID()]
|
||||
c.Unlock()
|
||||
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
@ -454,7 +459,12 @@ func (sb *sandbox) ResolveService(name string) ([]*net.SRV, []net.IP, error) {
|
|||
for _, ep := range sb.getConnectedEndpoints() {
|
||||
n := ep.getNetwork()
|
||||
|
||||
sr, ok := n.getController().svcRecords[n.ID()]
|
||||
c := n.getController()
|
||||
|
||||
c.Lock()
|
||||
sr, ok := c.svcRecords[n.ID()]
|
||||
c.Unlock()
|
||||
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
@ -575,7 +585,11 @@ func (sb *sandbox) resolveName(req string, networkName string, epList []*endpoin
|
|||
ep.Unlock()
|
||||
}
|
||||
|
||||
sr, ok := n.getController().svcRecords[n.ID()]
|
||||
c := n.getController()
|
||||
c.Lock()
|
||||
sr, ok := c.svcRecords[n.ID()]
|
||||
c.Unlock()
|
||||
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue