beam: fix FD leaks in SendPipe
This fixes file descriptor leaks in the SendPipe function. Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
3b5c1c4203
commit
5df3aaeda2
1 changed files with 4 additions and 4 deletions
|
@ -120,6 +120,7 @@ func SendPipe(conn *net.UnixConn, data []byte) (endpoint *net.UnixConn, err erro
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
local.Close()
|
||||
if err := Send(conn, data, remote); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -198,16 +199,15 @@ func USocketPair() (*net.UnixConn, *net.UnixConn, error) {
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer a.Close()
|
||||
defer b.Close()
|
||||
uA, err := FdConn(int(a.Fd()))
|
||||
if err != nil {
|
||||
a.Close()
|
||||
b.Close()
|
||||
return nil, nil, err
|
||||
}
|
||||
uB, err := FdConn(int(b.Fd()))
|
||||
if err != nil {
|
||||
a.Close()
|
||||
b.Close()
|
||||
uA.Close()
|
||||
return nil, nil, err
|
||||
}
|
||||
return uA, uB, nil
|
||||
|
|
Loading…
Reference in a new issue