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)
|
srv, err := socket.NewPluginServer(nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
plugincmd.Env = append(plugincmd.Env, socket.EnvKey+"="+srv.Addr().String())
|
plugincmd.Env = append(plugincmd.Env, socket.EnvKey+"="+srv.Addr().String())
|
||||||
}
|
|
||||||
defer func() {
|
defer func() {
|
||||||
// Close the server when plugin execution is over, so that in case
|
// Close the server when plugin execution is over, so that in case
|
||||||
// it's still open, any sockets on the filesystem are cleaned up.
|
// it's still open, any sockets on the filesystem are cleaned up.
|
||||||
_ = srv.Close()
|
_ = srv.Close()
|
||||||
}()
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// Set additional environment variables specified by the caller.
|
// Set additional environment variables specified by the caller.
|
||||||
plugincmd.Env = append(plugincmd.Env, envs...)
|
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,
|
// Repeated invocations will result in EINVAL,
|
||||||
// or EBADF; but that is fine for our purposes.
|
// or EBADF; but that is fine for our purposes.
|
||||||
|
if srv != nil {
|
||||||
_ = srv.Close()
|
_ = srv.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// force the process to terminate if it hasn't already
|
// force the process to terminate if it hasn't already
|
||||||
if force {
|
if force {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user