Both these defers were defined in the closure, and would be executed
at the end of the goroutine; inline them to prevent them being confused
for being executed after the function starting the goroutine.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -173,9 +173,9 @@ func (daemon *Daemon) containerAttach(ctr *container.Container, cfg *stream.Atta |
| 173 | 173 |
if cfg.Stdin != nil {
|
| 174 | 174 |
r, w := io.Pipe() |
| 175 | 175 |
go func(stdin io.ReadCloser) {
|
| 176 |
- defer w.Close() |
|
| 177 |
- defer log.G(context.TODO()).Debug("Closing buffered stdin pipe")
|
|
| 178 | 176 |
io.Copy(w, stdin) |
| 177 |
+ log.G(context.TODO()).Debug("Closing buffered stdin pipe")
|
|
| 178 |
+ w.Close() |
|
| 179 | 179 |
}(cfg.Stdin) |
| 180 | 180 |
cfg.Stdin = r |
| 181 | 181 |
} |