From cb54e9c659c681fde5311aacefe0e5ea8c564e17 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 9 Apr 2013 09:59:30 -0700 Subject: [PATCH 1/2] Flush whether or not there we set the rawmode to avoid the client to lock --- commands.go | 9 +++++---- rcli/tcp.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/commands.go b/commands.go index 29508ce0a3..9a520da8a0 100644 --- a/commands.go +++ b/commands.go @@ -803,9 +803,9 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout rcli.DockerConn, args . if container.Config.Tty { stdout.SetOptionRawTerminal() - // Flush the options to make sure the client sets the raw mode - stdout.Write([]byte{}) } + // Flush the options to make sure the client sets the raw mode + stdout.Flush() return <-container.Attach(stdin, nil, stdout, stdout) } @@ -893,9 +893,10 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout rcli.DockerConn, args ...s if config.Tty { stdout.SetOptionRawTerminal() - // Flush the options to make sure the client sets the raw mode - stdout.Flush() } + // Flush the options to make sure the client sets the raw mode + // or tell the client there is no options + stdout.Flush() // Create new container container, err := srv.runtime.Create(config) diff --git a/rcli/tcp.go b/rcli/tcp.go index 8c990ed82f..e9dba7f319 100644 --- a/rcli/tcp.go +++ b/rcli/tcp.go @@ -93,7 +93,7 @@ func (c *DockerTCPConn) Write(b []byte) (int, error) { } func (c *DockerTCPConn) Flush() error { - _, err := c.conn.Write([]byte{}) + _, err := c.Write([]byte{}) return err } From 1eaaa6b744b8017e7d31bdf9dc7095663b4c930c Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 9 Apr 2013 10:02:57 -0700 Subject: [PATCH 2/2] Flush stdout on import to avoid deadklock when waiting for stdin (import -). Fixed #365 --- commands.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands.go b/commands.go index 9a520da8a0..2c098d5196 100644 --- a/commands.go +++ b/commands.go @@ -419,7 +419,8 @@ func (srv *Server) CmdKill(stdin io.ReadCloser, stdout io.Writer, args ...string return nil } -func (srv *Server) CmdImport(stdin io.ReadCloser, stdout io.Writer, args ...string) error { +func (srv *Server) CmdImport(stdin io.ReadCloser, stdout rcli.DockerConn, args ...string) error { + stdout.Flush() cmd := rcli.Subcmd(stdout, "import", "[OPTIONS] URL|- [REPOSITORY [TAG]]", "Create a new filesystem image from the contents of a tarball") var archive io.Reader var resp *http.Response