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)
|
||||
}
|
||||
|
||||
// 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()
|
||||
|
||||
name1, name2, err := createVethPair()
|
||||
|
|
|
@ -118,15 +118,13 @@ func (d *driver) DeleteNetwork(nid string) error {
|
|||
return n.releaseVxlanID()
|
||||
}
|
||||
|
||||
func (n *network) joinSandbox() error {
|
||||
func (n *network) incEndpointCount() {
|
||||
n.Lock()
|
||||
if n.joinCnt != 0 {
|
||||
n.joinCnt++
|
||||
n.Unlock()
|
||||
return nil
|
||||
}
|
||||
n.Unlock()
|
||||
defer n.Unlock()
|
||||
n.joinCnt++
|
||||
}
|
||||
|
||||
func (n *network) joinSandbox() error {
|
||||
// If there is a race between two go routines here only one will win
|
||||
// the other will wait.
|
||||
n.once.Do(func() {
|
||||
|
@ -139,20 +137,10 @@ func (n *network) joinSandbox() error {
|
|||
}
|
||||
|
||||
func (n *network) joinSubnetSandbox(s *subnet) error {
|
||||
|
||||
s.once.Do(func() {
|
||||
s.initErr = n.initSubnetSandbox(s)
|
||||
})
|
||||
// Increment joinCnt in all the goroutines only when the one time initSandbox
|
||||
// was a success.
|
||||
n.Lock()
|
||||
if s.initErr == nil {
|
||||
n.joinCnt++
|
||||
}
|
||||
err := s.initErr
|
||||
n.Unlock()
|
||||
|
||||
return err
|
||||
return s.initErr
|
||||
}
|
||||
|
||||
func (n *network) leaveSandbox() {
|
||||
|
|
Loading…
Add table
Reference in a new issue