Close opened netns
This commit is contained in:
1 parent
fd5e1970e1
commit
9b32bc2ab3
1 file changed
+2
@@ -130,6 +130,7 @@ func GetNetDevsWithPredicate(processID int, predicate func(link netlink.Link) bo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to open root namespace: %s", err)
|
return nil, fmt.Errorf("unable to open root namespace: %s", err)
|
||||||
}
|
}
|
||||||
|
defer nsToplevel.Close()
|
||||||
nsContainr, err := netns.GetFromPid(processID)
|
nsContainr, err := netns.GetFromPid(processID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
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)
|
return nil, fmt.Errorf("unable to open process %d namespace: %s", processID, err)
|
||||||
}
|
}
|
||||||
|
defer nsContainr.Close()
|
||||||
if nsToplevel.Equal(nsContainr) {
|
if nsToplevel.Equal(nsContainr) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user