mirror of
https://github.com/golang/go
synced 2024-11-20 04:54:44 -07:00
net: add missing close socket code
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/6868067
This commit is contained in:
parent
feb95a802e
commit
87b315a78f
@ -557,7 +557,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (*netFD, error) {
|
||||
s, err := syscall.Socket(fd.family, fd.sotype, 0)
|
||||
if err != nil {
|
||||
syscall.ForkLock.RUnlock()
|
||||
return nil, err
|
||||
return nil, &OpError{"socket", fd.net, fd.laddr, err}
|
||||
}
|
||||
syscall.CloseOnExec(s)
|
||||
syscall.ForkLock.RUnlock()
|
||||
@ -565,6 +565,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (*netFD, error) {
|
||||
// Associate our new socket with IOCP.
|
||||
onceStartServer.Do(startServer)
|
||||
if _, err := syscall.CreateIoCompletionPort(s, resultsrv.iocp, 0, 0); err != nil {
|
||||
closesocket(s)
|
||||
return nil, &OpError{"CreateIoCompletionPort", fd.net, fd.laddr, err}
|
||||
}
|
||||
|
||||
@ -582,7 +583,7 @@ func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (*netFD, error) {
|
||||
err = syscall.Setsockopt(s, syscall.SOL_SOCKET, syscall.SO_UPDATE_ACCEPT_CONTEXT, (*byte)(unsafe.Pointer(&fd.sysfd)), int32(unsafe.Sizeof(fd.sysfd)))
|
||||
if err != nil {
|
||||
closesocket(s)
|
||||
return nil, err
|
||||
return nil, &OpError{"Setsockopt", fd.net, fd.laddr, err}
|
||||
}
|
||||
|
||||
// Get local and peer addr out of AcceptEx buffer.
|
||||
|
@ -332,6 +332,7 @@ func TestReadWriteDeadline(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("ListenTCP on :0: %v", err)
|
||||
}
|
||||
defer ln.Close()
|
||||
|
||||
lnquit := make(chan bool)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user