Browse code

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>

Kenfe-Mickael Laventure authored on 2016/07/27 11:17:22
Showing 1 changed files
... ...
@@ -119,22 +119,6 @@ func (daemon *Daemon) AttachStreams(id string, iop libcontainerd.IOPipe) error {
119 119
 		}
120 120
 	}
121 121
 
122
-	if stdin := s.Stdin(); stdin != nil {
123
-		if iop.Stdin != nil {
124
-			go func() {
125
-				io.Copy(iop.Stdin, stdin)
126
-				iop.Stdin.Close()
127
-			}()
128
-		}
129
-	} else {
130
-		if c != nil && !c.Config.Tty {
131
-			// tty is enabled, so dont close containerd's iopipe stdin.
132
-			if iop.Stdin != nil {
133
-				iop.Stdin.Close()
134
-			}
135
-		}
136
-	}
137
-
138 122
 	copyFunc := func(w io.Writer, r io.Reader) {
139 123
 		s.Add(1)
140 124
 		go func() {
... ...
@@ -152,5 +136,21 @@ func (daemon *Daemon) AttachStreams(id string, iop libcontainerd.IOPipe) error {
152 152
 		copyFunc(s.Stderr(), iop.Stderr)
153 153
 	}
154 154
 
155
+	if stdin := s.Stdin(); stdin != nil {
156
+		if iop.Stdin != nil {
157
+			go func() {
158
+				io.Copy(iop.Stdin, stdin)
159
+				iop.Stdin.Close()
160
+			}()
161
+		}
162
+	} else {
163
+		if c != nil && !c.Config.Tty {
164
+			// tty is enabled, so dont close containerd's iopipe stdin.
165
+			if iop.Stdin != nil {
166
+				iop.Stdin.Close()
167
+			}
168
+		}
169
+	}
170
+
155 171
 	return nil
156 172
 }