summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-07-14 13:39:58 -0400
committerGitHub <noreply@github.com>2021-07-14 13:39:58 -0400
commitace19c75ad61f96239996959aee0db361abbf501 (patch)
treef0f80c58facd06f9c55df651ef7cc5fcf09ac853 /pkg/bindings
parent9d98f56a64852d3bf9d3b27ad6e1ac3e3ebb6622 (diff)
parentcbbb1a80f5ccbbec5496f253cabce0f65df0f656 (diff)
downloadpodman-ace19c75ad61f96239996959aee0db361abbf501.tar.gz
podman-ace19c75ad61f96239996959aee0db361abbf501.tar.bz2
podman-ace19c75ad61f96239996959aee0db361abbf501.zip
Merge pull request #10916 from mheon/fix_7360
Perform a one-sided close of HTTP attach conn on EOF
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/containers/attach.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/bindings/containers/attach.go b/pkg/bindings/containers/attach.go
index cc12c8ab7..01c14d350 100644
--- a/pkg/bindings/containers/attach.go
+++ b/pkg/bindings/containers/attach.go
@@ -25,6 +25,12 @@ import (
"golang.org/x/crypto/ssh/terminal"
)
+// The CloseWriter interface is used to determine whether we can do a one-sided
+// close of a hijacked connection.
+type CloseWriter interface {
+ CloseWrite() error
+}
+
// Attach attaches to a running container
func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Writer, stderr io.Writer, attachReady chan bool, options *AttachOptions) error {
if options == nil {
@@ -161,6 +167,12 @@ func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Wri
logrus.Error("failed to write input to service: " + err.Error())
}
stdinChan <- err
+
+ if closeWrite, ok := socket.(CloseWriter); ok {
+ if err := closeWrite.CloseWrite(); err != nil {
+ logrus.Warnf("Failed to close STDIN for writing: %v", err)
+ }
+ }
}()
}
@@ -485,6 +497,13 @@ func ExecStartAndAttach(ctx context.Context, sessionID string, options *ExecStar
if err != nil {
logrus.Error("failed to write input to service: " + err.Error())
}
+
+ if closeWrite, ok := socket.(CloseWriter); ok {
+ logrus.Debugf("Closing STDIN")
+ if err := closeWrite.CloseWrite(); err != nil {
+ logrus.Warnf("Failed to close STDIN for writing: %v", err)
+ }
+ }
}()
}