Close opened netns

This commit is contained in:
Martynas Pumputis committed 2016-09-14 16:47:40 +01:00
1 parent fd5e1970e1
commit 9b32bc2ab3
1 file changed
+2
+2
View File
@@ -130,6 +130,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo
if err != nil {
return nil, fmt.Errorf("unable to open root namespace: %s", err)
}
defer nsToplevel.Close()
nsContainr, err := netns.GetFromPid(processID)
if err != nil {
if os.IsNotExist(err) {
@@ -137,6 +138,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo
}
return nil, fmt.Errorf("unable to open process %d namespace: %s", processID, err)
}
defer nsContainr.Close()
if nsToplevel.Equal(nsContainr) {
return nil, nil
}