mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-28 08:27:42 +08:00
Merge pull request #1772 from tonistiigi/container-hang-fix
container-driver: avoid hanging on container panic
This commit is contained in:
commit
4fa7cd1fc2
@ -9,6 +9,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/docker/buildx/driver"
|
||||
@ -369,7 +370,11 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
|
||||
}
|
||||
|
||||
var opts []client.ClientOpt
|
||||
var counter int64
|
||||
opts = append(opts, client.WithContextDialer(func(context.Context, string) (net.Conn, error) {
|
||||
if atomic.AddInt64(&counter, 1) > 1 {
|
||||
return nil, net.ErrClosed
|
||||
}
|
||||
return conn, nil
|
||||
}))
|
||||
if td, ok := exp.(client.TracerDelegate); ok {
|
||||
@ -395,7 +400,10 @@ func (d *Driver) Features() map[driver.Feature]bool {
|
||||
func demuxConn(c net.Conn) net.Conn {
|
||||
pr, pw := io.Pipe()
|
||||
// TODO: rewrite parser with Reader() to avoid goroutine switch
|
||||
go stdcopy.StdCopy(pw, os.Stderr, c)
|
||||
go func() {
|
||||
_, err := stdcopy.StdCopy(pw, os.Stderr, c)
|
||||
pw.CloseWithError(err)
|
||||
}()
|
||||
return &demux{
|
||||
Conn: c,
|
||||
Reader: pr,
|
||||
|
Loading…
x
Reference in New Issue
Block a user