mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Attach stdin after attach stdout/err to avoid an rpc lock
Reason of the lock is currently unknown Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
646f04799c
commit
e1a61dc264
1 changed files with 17 additions and 17 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue