Browse code

daemon: daemon.containerAttach: remove redundant defers

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>

Sebastiaan van Stijn authored on 2025/03/23 20:18:46
Showing 1 changed files
... ...
@@ -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
 	}