mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #629 from sanimej/slice
Fix the overlay cleanup in the multi-subnet case
This commit is contained in:
commit
fb19b4f488
2 changed files with 10 additions and 18 deletions
|
@ -43,6 +43,10 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
|
||||||
return fmt.Errorf("subnet sandbox join failed for %q: %v", s.subnetIP.String(), err)
|
return fmt.Errorf("subnet sandbox join failed for %q: %v", s.subnetIP.String(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// joinSubnetSandbox gets called when an endpoint comes up on a new subnet in the
|
||||||
|
// overlay network. Hence the Endpoint count should be updated outside joinSubnetSandbox
|
||||||
|
n.incEndpointCount()
|
||||||
|
|
||||||
sbox := n.sandbox()
|
sbox := n.sandbox()
|
||||||
|
|
||||||
name1, name2, err := createVethPair()
|
name1, name2, err := createVethPair()
|
||||||
|
|
|
@ -118,15 +118,13 @@ func (d *driver) DeleteNetwork(nid string) error {
|
||||||
return n.releaseVxlanID()
|
return n.releaseVxlanID()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) joinSandbox() error {
|
func (n *network) incEndpointCount() {
|
||||||
n.Lock()
|
n.Lock()
|
||||||
if n.joinCnt != 0 {
|
defer n.Unlock()
|
||||||
n.joinCnt++
|
n.joinCnt++
|
||||||
n.Unlock()
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
n.Unlock()
|
|
||||||
|
|
||||||
|
func (n *network) joinSandbox() error {
|
||||||
// If there is a race between two go routines here only one will win
|
// If there is a race between two go routines here only one will win
|
||||||
// the other will wait.
|
// the other will wait.
|
||||||
n.once.Do(func() {
|
n.once.Do(func() {
|
||||||
|
@ -139,20 +137,10 @@ func (n *network) joinSandbox() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) joinSubnetSandbox(s *subnet) error {
|
func (n *network) joinSubnetSandbox(s *subnet) error {
|
||||||
|
|
||||||
s.once.Do(func() {
|
s.once.Do(func() {
|
||||||
s.initErr = n.initSubnetSandbox(s)
|
s.initErr = n.initSubnetSandbox(s)
|
||||||
})
|
})
|
||||||
// Increment joinCnt in all the goroutines only when the one time initSandbox
|
return s.initErr
|
||||||
// was a success.
|
|
||||||
n.Lock()
|
|
||||||
if s.initErr == nil {
|
|
||||||
n.joinCnt++
|
|
||||||
}
|
|
||||||
err := s.initErr
|
|
||||||
n.Unlock()
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) leaveSandbox() {
|
func (n *network) leaveSandbox() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue