зеркало из https://github.com/microsoft/docker.git
Add CloseWriters back and do an interface cast
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Родитель
592c2f6f9a
Коммит
8e2284aaa2
|
@ -829,10 +829,10 @@ func (container *Container) cleanup() {
|
||||||
utils.Errorf("%s: Error close stdin: %s", container.ID, err)
|
utils.Errorf("%s: Error close stdin: %s", container.ID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := container.stdout.Close(); err != nil {
|
if err := container.stdout.CloseWriters(); err != nil {
|
||||||
utils.Errorf("%s: Error close stdout: %s", container.ID, err)
|
utils.Errorf("%s: Error close stdout: %s", container.ID, err)
|
||||||
}
|
}
|
||||||
if err := container.stderr.Close(); err != nil {
|
if err := container.stderr.CloseWriters(); err != nil {
|
||||||
utils.Errorf("%s: Error close stderr: %s", container.ID, err)
|
utils.Errorf("%s: Error close stderr: %s", container.ID, err)
|
||||||
}
|
}
|
||||||
if container.command.Terminal != nil {
|
if container.command.Terminal != nil {
|
||||||
|
|
|
@ -14,10 +14,10 @@ type Term interface {
|
||||||
|
|
||||||
type Pipes struct {
|
type Pipes struct {
|
||||||
Stdin io.ReadCloser
|
Stdin io.ReadCloser
|
||||||
Stdout, Stderr io.WriteCloser
|
Stdout, Stderr io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPipes(stdin io.ReadCloser, stdout, stderr io.WriteCloser, useStdin bool) *Pipes {
|
func NewPipes(stdin io.ReadCloser, stdout, stderr io.Writer, useStdin bool) *Pipes {
|
||||||
p := &Pipes{
|
p := &Pipes{
|
||||||
Stdout: stdout,
|
Stdout: stdout,
|
||||||
Stderr: stderr,
|
Stderr: stderr,
|
||||||
|
@ -76,7 +76,11 @@ func (t *TtyConsole) attach(command *Command, pipes *Pipes) error {
|
||||||
command.Console = t.Slave.Name()
|
command.Console = t.Slave.Name()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer pipes.Stdout.Close()
|
if wb, ok := pipes.Stdout.(interface {
|
||||||
|
CloseWriters() error
|
||||||
|
}); ok {
|
||||||
|
defer wb.CloseWriters()
|
||||||
|
}
|
||||||
io.Copy(pipes.Stdout, t.Master)
|
io.Copy(pipes.Stdout, t.Master)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,7 @@ func (w *WriteBroadcaster) Write(p []byte) (n int, err error) {
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *WriteBroadcaster) Close() error {
|
func (w *WriteBroadcaster) CloseWriters() error {
|
||||||
w.Lock()
|
w.Lock()
|
||||||
defer w.Unlock()
|
defer w.Unlock()
|
||||||
for sw := range w.writers {
|
for sw := range w.writers {
|
||||||
|
|
|
@ -110,7 +110,7 @@ func TestWriteBroadcaster(t *testing.T) {
|
||||||
t.Errorf("Buffer contains %v", bufferC.String())
|
t.Errorf("Buffer contains %v", bufferC.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Close()
|
writer.CloseWriters()
|
||||||
}
|
}
|
||||||
|
|
||||||
type devNullCloser int
|
type devNullCloser int
|
||||||
|
|
Загрузка…
Ссылка в новой задаче