Commit 4855c1c1 authored by Alex Brainman's avatar Alex Brainman

net: change windows netFD finalizer to behave similar to unix

R=dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6873046
parent a7c57b05
...@@ -300,7 +300,6 @@ func allocFD(fd syscall.Handle, family, sotype int, net string) *netFD { ...@@ -300,7 +300,6 @@ func allocFD(fd syscall.Handle, family, sotype int, net string) *netFD {
net: net, net: net,
closec: make(chan bool), closec: make(chan bool),
} }
runtime.SetFinalizer(netfd, (*netFD).Close)
return netfd return netfd
} }
...@@ -319,6 +318,7 @@ func newFD(fd syscall.Handle, family, proto int, net string) (*netFD, error) { ...@@ -319,6 +318,7 @@ func newFD(fd syscall.Handle, family, proto int, net string) (*netFD, error) {
func (fd *netFD) setAddr(laddr, raddr Addr) { func (fd *netFD) setAddr(laddr, raddr Addr) {
fd.laddr = laddr fd.laddr = laddr
fd.raddr = raddr fd.raddr = raddr
runtime.SetFinalizer(fd, (*netFD).closesocket)
} }
func (fd *netFD) connect(ra syscall.Sockaddr) error { func (fd *netFD) connect(ra syscall.Sockaddr) error {
...@@ -398,6 +398,10 @@ func (fd *netFD) CloseWrite() error { ...@@ -398,6 +398,10 @@ func (fd *netFD) CloseWrite() error {
return fd.shutdown(syscall.SHUT_WR) return fd.shutdown(syscall.SHUT_WR)
} }
func (fd *netFD) closesocket() error {
return closesocket(fd.sysfd)
}
// Read from network. // Read from network.
type readOp struct { type readOp struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment