From 51f698337ddf5464dcac01c0ce9ac10a677d0f99 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Tue, 16 May 2017 14:32:29 -0700 Subject: [PATCH] Avoid loop when discarding contents of progress pipe Signed-off-by: Aaron Lehmann --- cli/command/service/helpers.go | 10 ++-------- cli/command/swarm/ca.go | 8 +------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/cli/command/service/helpers.go b/cli/command/service/helpers.go index 50aee7c88f..2e893f96e1 100644 --- a/cli/command/service/helpers.go +++ b/cli/command/service/helpers.go @@ -2,6 +2,7 @@ package service import ( "io" + "io/ioutil" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/service/progress" @@ -20,14 +21,7 @@ func waitOnService(ctx context.Context, dockerCli *command.DockerCli, serviceID }() if opts.quiet { - go func() { - for { - var buf [1024]byte - if _, err := pipeReader.Read(buf[:]); err != nil { - return - } - } - }() + go io.Copy(ioutil.Discard, pipeReader) return <-errChan } diff --git a/cli/command/swarm/ca.go b/cli/command/swarm/ca.go index 0814a53950..fab0929b64 100644 --- a/cli/command/swarm/ca.go +++ b/cli/command/swarm/ca.go @@ -102,13 +102,7 @@ func runRotateCA(dockerCli command.Cli, flags *pflag.FlagSet, opts caOptions) er }() if opts.quiet { - go func() { - for { - if _, err := io.Copy(ioutil.Discard, pipeReader); err != nil { - return - } - } - }() + go io.Copy(ioutil.Discard, pipeReader) return <-errChan }