Merge pull request #25129 from mlaventure/fix-weird-rpc-lock-on-master

Attach stdin after attach stdout/err to avoid an rpc lock
This commit is contained in:
Alexander Morozov 2016-08-01 14:52:09 -07:00 committed by GitHub
commit 67a47d78a1
1 changed files with 17 additions and 17 deletions

View File

@ -125,6 +125,23 @@ func (daemon *Daemon) AttachStreams(id string, iop libcontainerd.IOPipe) error {
}
}
copyFunc := func(w io.Writer, r io.Reader) {
s.Add(1)
go func() {
if _, err := io.Copy(w, r); err != nil {
logrus.Errorf("%v stream copy error: %v", id, err)
}
s.Done()
}()
}
if iop.Stdout != nil {
copyFunc(s.Stdout(), iop.Stdout)
}
if iop.Stderr != nil {
copyFunc(s.Stderr(), iop.Stderr)
}
if stdin := s.Stdin(); stdin != nil {
if iop.Stdin != nil {
go func() {
@ -144,22 +161,5 @@ func (daemon *Daemon) AttachStreams(id string, iop libcontainerd.IOPipe) error {
}
}
copyFunc := func(w io.Writer, r io.Reader) {
s.Add(1)
go func() {
if _, err := io.Copy(w, r); err != nil {
logrus.Errorf("%v stream copy error: %v", id, err)
}
s.Done()
}()
}
if iop.Stdout != nil {
copyFunc(s.Stdout(), iop.Stdout)
}
if iop.Stderr != nil {
copyFunc(s.Stderr(), iop.Stderr)
}
return nil
}