Defer netns.Close() after error check
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
This commit is contained in:
parent
191def7029
commit
7a978e354a
|
@ -1335,11 +1335,11 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error {
|
||||||
// The <key> needs to be the same as during checkpointing.
|
// The <key> needs to be the same as during checkpointing.
|
||||||
// We are always using 'extRootNetNS' as the key in this.
|
// We are always using 'extRootNetNS' as the key in this.
|
||||||
netns, err := os.Open(nsPath)
|
netns, err := os.Open(nsPath)
|
||||||
defer netns.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("If a specific network namespace is defined it must exist: %s", err)
|
logrus.Errorf("If a specific network namespace is defined it must exist: %s", err)
|
||||||
return fmt.Errorf("Requested network namespace %v does not exist", nsPath)
|
return fmt.Errorf("Requested network namespace %v does not exist", nsPath)
|
||||||
}
|
}
|
||||||
|
defer netns.Close()
|
||||||
inheritFd := new(criurpc.InheritFd)
|
inheritFd := new(criurpc.InheritFd)
|
||||||
inheritFd.Key = proto.String("extRootNetNS")
|
inheritFd.Key = proto.String("extRootNetNS")
|
||||||
// The offset of four is necessary because 0, 1, 2 and 3 is already
|
// The offset of four is necessary because 0, 1, 2 and 3 is already
|
||||||
|
|
Loading…
Reference in New Issue