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

Attach stdin after attach stdout/err to avoid an rpc lock
Upstream-commit: 67a47d78a18d799719df61b93a54a246eb97b209
Component: engine
This commit is contained in:
Alexander Morozov
2016-08-01 14:52:09 -07:00
committed by GitHub
+17 -17
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
}