Browse Source

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

Attach stdin after attach stdout/err to avoid an rpc lock
Sebastiaan van Stijn 9 years ago
parent
commit
c62b19f1e3
1 changed files with 16 additions and 16 deletions
  1. 16 16
      daemon/monitor.go

+ 16 - 16
daemon/monitor.go

@@ -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
 }