only close plugin server if actually created
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
9e506545fd
commit
b9c563a581
@ -302,12 +302,12 @@ func tryPluginRun(ctx context.Context, dockerCli command.Cli, cmd *cobra.Command
|
||||
srv, err := socket.NewPluginServer(nil)
|
||||
if err == nil {
|
||||
plugincmd.Env = append(plugincmd.Env, socket.EnvKey+"="+srv.Addr().String())
|
||||
defer func() {
|
||||
// Close the server when plugin execution is over, so that in case
|
||||
// it's still open, any sockets on the filesystem are cleaned up.
|
||||
_ = srv.Close()
|
||||
}()
|
||||
}
|
||||
defer func() {
|
||||
// Close the server when plugin execution is over, so that in case
|
||||
// it's still open, any sockets on the filesystem are cleaned up.
|
||||
_ = srv.Close()
|
||||
}()
|
||||
|
||||
// Set additional environment variables specified by the caller.
|
||||
plugincmd.Env = append(plugincmd.Env, envs...)
|
||||
@ -334,7 +334,9 @@ func tryPluginRun(ctx context.Context, dockerCli command.Cli, cmd *cobra.Command
|
||||
//
|
||||
// Repeated invocations will result in EINVAL,
|
||||
// or EBADF; but that is fine for our purposes.
|
||||
_ = srv.Close()
|
||||
if srv != nil {
|
||||
_ = srv.Close()
|
||||
}
|
||||
|
||||
// force the process to terminate if it hasn't already
|
||||
if force {
|
||||
|
Loading…
x
Reference in New Issue
Block a user