Skip to content

Commit 23c7b74

Browse files
committed
only close plugin server if actually created
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 9e50654 commit 23c7b74

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

cmd/docker/docker.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@ func tryPluginRun(ctx context.Context, dockerCli command.Cli, cmd *cobra.Command
302302
srv, err := socket.NewPluginServer(nil)
303303
if err == nil {
304304
plugincmd.Env = append(plugincmd.Env, socket.EnvKey+"="+srv.Addr().String())
305+
defer func() {
306+
// Close the server when plugin execution is over, so that in case
307+
// it's still open, any sockets on the filesystem are cleaned up.
308+
_ = srv.Close()
309+
}()
305310
}
306-
defer func() {
307-
// Close the server when plugin execution is over, so that in case
308-
// it's still open, any sockets on the filesystem are cleaned up.
309-
_ = srv.Close()
310-
}()
311311

312312
// Set additional environment variables specified by the caller.
313313
plugincmd.Env = append(plugincmd.Env, envs...)

0 commit comments

Comments
 (0)