mirror of
https://github.com/golang/go
synced 2024-11-25 11:37:57 -07:00
net: fix socket leak in case of Dial failure
Socket descriptors are not closed when fd.connect() fails during generic socket creation. After a connection failure [ECONNREFUSED] descriptors are left in SYN_SENT state indefinitely (unless they get an explicit RST). Repeated failed connections will eventually cause your program to hit the user/system max-open-files limit. Fixes #2349. R=golang-dev, mikioh.mikioh CC=golang-dev https://golang.org/cl/5229047
This commit is contained in:
parent
1444a08098
commit
4b749567b8
@ -52,6 +52,7 @@ func socket(net string, f, p, t int, la, ra syscall.Sockaddr, toAddr func(syscal
|
|||||||
|
|
||||||
if ra != nil {
|
if ra != nil {
|
||||||
if err = fd.connect(ra); err != nil {
|
if err = fd.connect(ra); err != nil {
|
||||||
|
closesocket(s)
|
||||||
fd.Close()
|
fd.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user