From 39b2295e3ef0a3bc6b96b015afd3f7efbc6915b4 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 12 Apr 2018 14:07:26 -0400 Subject: Fix another comparison of a Go interface against nil Signed-off-by: Matthew Heon Closes: #608 Approved by: baude --- libpod/container_attach.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libpod') diff --git a/libpod/container_attach.go b/libpod/container_attach.go index f5b97c2dd..3677a3d78 100644 --- a/libpod/container_attach.go +++ b/libpod/container_attach.go @@ -92,7 +92,7 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi receiveStdoutError := make(chan error) if streams.AttachOutput || streams.AttachError { go func() { - receiveStdoutError <- redirectResponseToOutputStreams(streams.OutputStream, streams.ErrorStream, conn) + receiveStdoutError <- redirectResponseToOutputStreams(streams.OutputStream, streams.ErrorStream, streams.AttachOutput, streams.AttachError, conn) }() } @@ -120,23 +120,26 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi return nil } -func redirectResponseToOutputStreams(outputStream, errorStream io.Writer, conn io.Reader) error { +func redirectResponseToOutputStreams(outputStream, errorStream io.Writer, writeOutput, writeError bool, conn io.Reader) error { var err error buf := make([]byte, 8192+1) /* Sync with conmon STDIO_BUF_SIZE */ for { nr, er := conn.Read(buf) if nr > 0 { var dst io.Writer + var doWrite bool switch buf[0] { case AttachPipeStdout: dst = outputStream + doWrite = writeOutput case AttachPipeStderr: dst = errorStream + doWrite = writeError default: logrus.Infof("Received unexpected attach type %+d", buf[0]) } - if dst != nil { + if doWrite { nw, ew := dst.Write(buf[1:nr]) if ew != nil { err = ew -- cgit v1.2.3-54-g00ecf