Skip to content

Commit

Permalink
Repair (*Broadcaster).run goroutine leak
Browse files Browse the repository at this point in the history
When execute 'docker swarm init' and 'docker swarm leave -f' on a node
repeatedly, the (*Broadcaster).run goroutine leak.

Signed-off-by: yangchenliang <[email protected]>
  • Loading branch information
ityangchen committed Sep 28, 2017
1 parent 6ea54e5 commit db55212
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 7 additions & 8 deletions drivers/overlay/ov_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,16 +715,15 @@ func (n *network) initSandbox(restore bool) error {
func (n *network) watchMiss(nlSock *nl.NetlinkSocket) {
t := time.Now()
for {
n.Lock()
nlFd := nlSock.GetFd()
n.Unlock()
if nlFd == -1 {
// The netlink socket got closed, simply exit to not leak this goroutine
return
}

msgs, err := nlSock.Receive()
if err != nil {
n.Lock()
nlFd := nlSock.GetFd()
n.Unlock()
if nlFd == -1 {
// The netlink socket got closed, simply exit to not leak this goroutine
return
}
logrus.Errorf("Failed to receive from netlink: %v ", err)
continue
}
Expand Down
1 change: 1 addition & 0 deletions networkdb/networkdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func (nDB *NetworkDB) Close() {
logrus.Errorf("Could not close DB %s: %v", nDB.config.NodeName, err)
}

//Avoid (*Broadcaster).run goroutine leak
nDB.broadcaster.Close()
}

Expand Down

0 comments on commit db55212

Please sign in to comment.