summaryrefslogtreecommitdiff
path: root/libpod/container_attach.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-04-12 14:07:26 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-04-13 18:43:44 +0000
commit39b2295e3ef0a3bc6b96b015afd3f7efbc6915b4 (patch)
treeb34eb437bc97acf09561eb3447c4c8cf3cfe07c9 /libpod/container_attach.go
parent2961c9e293c162f0d4076a8c910bcc60c06610c0 (diff)
downloadpodman-39b2295e3ef0a3bc6b96b015afd3f7efbc6915b4.tar.gz
podman-39b2295e3ef0a3bc6b96b015afd3f7efbc6915b4.tar.bz2
podman-39b2295e3ef0a3bc6b96b015afd3f7efbc6915b4.zip
Fix another comparison of a Go interface against nil
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #608 Approved by: baude
Diffstat (limited to 'libpod/container_attach.go')
-rw-r--r--libpod/container_attach.go9
1 files changed, 6 insertions, 3 deletions
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