Merge pull request #25126 from mlaventure/fix-weird-rpc-lock

Attach stdin after attach stdout/err to avoid an rpc lock
This commit is contained in:
Sebastiaan van Stijn 2016-07-27 18:53:07 +02:00 committed by GitHub
commit c62b19f1e3

View file

@ -119,22 +119,6 @@ func (daemon *Daemon) AttachStreams(id string, iop libcontainerd.IOPipe) error {
}
}
if stdin := s.Stdin(); stdin != nil {
if iop.Stdin != nil {
go func() {
io.Copy(iop.Stdin, stdin)
iop.Stdin.Close()
}()
}
} else {
if c != nil && !c.Config.Tty {
// tty is enabled, so dont close containerd's iopipe stdin.
if iop.Stdin != nil {
iop.Stdin.Close()
}
}
}
copyFunc := func(w io.Writer, r io.Reader) {
s.Add(1)
go func() {
@ -152,5 +136,21 @@ func (daemon *Daemon) AttachStreams(id string, iop libcontainerd.IOPipe) error {
copyFunc(s.Stderr(), iop.Stderr)
}
if stdin := s.Stdin(); stdin != nil {
if iop.Stdin != nil {
go func() {
io.Copy(iop.Stdin, stdin)
iop.Stdin.Close()
}()
}
} else {
if c != nil && !c.Config.Tty {
// tty is enabled, so dont close containerd's iopipe stdin.
if iop.Stdin != nil {
iop.Stdin.Close()
}
}
}
return nil
}