diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-09-24 20:49:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 20:49:48 +0000 |
commit | 90c2cc6c8342e96ca0a21e59c3cdb7761b2229ea (patch) | |
tree | 09320c86d95c9bf6c64d106c3be6882e29b5cb13 /libpod/oci_conmon_linux.go | |
parent | 684cde87fa8f78a2ba7389e6eecd36dda00cfdff (diff) | |
parent | 00cca405d2cd0c3cd70f45ebc23337b033cca74a (diff) | |
download | podman-90c2cc6c8342e96ca0a21e59c3cdb7761b2229ea.tar.gz podman-90c2cc6c8342e96ca0a21e59c3cdb7761b2229ea.tar.bz2 podman-90c2cc6c8342e96ca0a21e59c3cdb7761b2229ea.zip |
Merge pull request #7762 from mheon/maybe_this_works
HTTP Attach: Wait until both STDIN and STDOUT finish
Diffstat (limited to 'libpod/oci_conmon_linux.go')
-rw-r--r-- | libpod/oci_conmon_linux.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index e3f2d6403..1d4f33794 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -555,9 +555,6 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. return err } - // Make a channel to pass errors back - errChan := make(chan error) - attachStdout := true attachStderr := true attachStdin := true @@ -672,6 +669,9 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. logrus.Debugf("Forwarding attach output for container %s", ctr.ID()) + stdoutChan := make(chan error) + stdinChan := make(chan error) + // Handle STDOUT/STDERR go func() { var err error @@ -690,7 +690,7 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. logrus.Debugf("Performing non-terminal HTTP attach for container %s", ctr.ID()) err = httpAttachNonTerminalCopy(conn, httpBuf, ctr.ID(), attachStdin, attachStdout, attachStderr) } - errChan <- err + stdoutChan <- err logrus.Debugf("STDOUT/ERR copy completed") }() // Next, STDIN. Avoid entirely if attachStdin unset. @@ -698,20 +698,25 @@ func (r *ConmonOCIRuntime) HTTPAttach(ctr *Container, req *http.Request, w http. go func() { _, err := utils.CopyDetachable(conn, httpBuf, detach) logrus.Debugf("STDIN copy completed") - errChan <- err + stdinChan <- err }() } - if cancel != nil { + for { select { - case err := <-errChan: - return err + case err := <-stdoutChan: + if err != nil { + return err + } + + return nil + case err := <-stdinChan: + if err != nil { + return err + } case <-cancel: return nil } - } else { - var connErr error = <-errChan - return connErr } } |