docker: close hijacked write connection when exec ends (#24244)

This commit is contained in:
Seth Hoenig
2024-10-17 11:41:29 -05:00
committed by GitHub
parent b18851617f
commit b539b54c9e
2 changed files with 8 additions and 1 deletions

3
.changelog/24244.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
docker: Fixed a bug where alloc exec could leak a goroutine
```

View File

@@ -1836,7 +1836,11 @@ func (d *Driver) ExecTaskStreaming(ctx context.Context, taskID string, opts *dri
if err != nil {
return nil, fmt.Errorf("failed to attach to exec: %v", err)
}
defer resp.Close()
defer func() {
opts.Stdin.Close() // close stdin
resp.CloseWrite() // close hijacked write connection
resp.Close() // close read connection
}()
go func() {
if !opts.Tty {