From 6f2fd272da8499b4fba352f83505d1774e0af0af Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Mon, 3 Jun 2013 17:39:29 -0700 Subject: [PATCH 1/3] Fix stale command with stdout is not allocated Upstream-commit: 0ca88443985e7a944106ed4ceaf877a97f1ca2ec Component: engine --- components/engine/container.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/components/engine/container.go b/components/engine/container.go index c6b7c8a51c..ef449653c4 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -355,6 +355,17 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s errors <- err }() } + } else { + go func() { + defer stdinCloser.Close() + + cStdout, err := container.StdoutPipe() + if err != nil { + utils.Debugf("Error stdout pipe") + return + } + io.Copy(&utils.NopWriter{}, cStdout) + }() } if stderr != nil { nJobs += 1 @@ -381,7 +392,19 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s errors <- err }() } + } else { + go func() { + defer stdinCloser.Close() + + cStderr, err := container.StdoutPipe() + if err != nil { + utils.Debugf("Error stdout pipe") + return + } + io.Copy(&utils.NopWriter{}, cStderr) + }() } + return utils.Go(func() error { if cStdout != nil { defer cStdout.Close() From 8f6d6bc6c70ccb7cae1ea5344be60e38d809b94c Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 4 Jun 2013 14:35:32 -0700 Subject: [PATCH 2/3] Fix nil pointer on some situatuion Upstream-commit: 63e80384ea753c74046c2a4c3f64229c359f466f Component: engine --- components/engine/container.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/components/engine/container.go b/components/engine/container.go index ef449653c4..0b54419122 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -357,14 +357,15 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s } } else { go func() { - defer stdinCloser.Close() - - cStdout, err := container.StdoutPipe() - if err != nil { - utils.Debugf("Error stdout pipe") - return + if stdinCloser != nil { + defer stdinCloser.Close() + } + + if cStdout, err := container.StdoutPipe(); err != nil { + utils.Debugf("Error stdout pipe") + } else { + io.Copy(&utils.NopWriter{}, cStdout) } - io.Copy(&utils.NopWriter{}, cStdout) }() } if stderr != nil { @@ -394,14 +395,15 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s } } else { go func() { - defer stdinCloser.Close() - - cStderr, err := container.StdoutPipe() - if err != nil { - utils.Debugf("Error stdout pipe") - return + if stdinCloser != nil { + defer stdinCloser.Close() + } + + if cStderr, err := container.StdoutPipe(); err != nil { + utils.Debugf("Error stdout pipe") + } else { + io.Copy(&utils.NopWriter{}, cStderr) } - io.Copy(&utils.NopWriter{}, cStderr) }() } From b9f9359558257843c3604241b52ce0a06ea3a902 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Mon, 10 Jun 2013 11:08:40 -0700 Subject: [PATCH 3/3] Fix typo Upstream-commit: 7169212683ba02e2da4c80792702c5210f1c16ea Component: engine --- components/engine/container.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/engine/container.go b/components/engine/container.go index 0b54419122..5db98ac382 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -399,7 +399,7 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s defer stdinCloser.Close() } - if cStderr, err := container.StdoutPipe(); err != nil { + if cStderr, err := container.StderrPipe(); err != nil { utils.Debugf("Error stdout pipe") } else { io.Copy(&utils.NopWriter{}, cStderr)