Skip to content

Commit

Permalink
Merge pull request moby#1065 from aboch/ov
Browse files Browse the repository at this point in the history
Do not allow overlay destroySandbox() to be interrupted
  • Loading branch information
mavenugo committed Mar 31, 2016
2 parents fa69adb + fe71e90 commit f7e3338
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/overlay/ov_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func (n *network) joinSubnetSandbox(s *subnet) error {

func (n *network) leaveSandbox() {
n.Lock()
defer n.Unlock()
n.joinCnt--
if n.joinCnt != 0 {
n.Unlock()
return
}

Expand All @@ -162,15 +162,14 @@ func (n *network) leaveSandbox() {
for _, s := range n.subnets {
s.once = &sync.Once{}
}
n.Unlock()

n.destroySandbox()
}

// to be called while holding network lock
func (n *network) destroySandbox() {
sbox := n.sandbox()
if sbox != nil {
for _, iface := range sbox.Info().Interfaces() {
if n.sbox != nil {
for _, iface := range n.sbox.Info().Interfaces() {
if err := iface.Remove(); err != nil {
logrus.Debugf("Remove interface %s failed: %v", iface.SrcName(), err)
}
Expand All @@ -197,8 +196,8 @@ func (n *network) destroySandbox() {
}
}

sbox.Destroy()
n.setSandbox(nil)
n.sbox.Destroy()
n.sbox = nil
}
}

Expand Down

0 comments on commit f7e3338

Please sign in to comment.