Commit f33f9b2c authored by Alex Brainman's avatar Alex Brainman

net: make windows (*netFD).connect work like its unix version

CL 17821 used syscall.CancelIoEx to cancel outstanding connect
call, but did not check for syscall.CancelIoEx return value.
Also I am worried about introducing race here. We should use
proper tools available for us instead. For example, we could
use fd.setWriteDeadline just like unix version does. Do that.

Change-Id: Idb9a03c8c249278ce3e2a4c49cc32445d4c7b065
Reviewed-on: https://go-review.googlesource.com/17920Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
parent a766d8e5
...@@ -357,15 +357,9 @@ func (fd *netFD) connect(la, ra syscall.Sockaddr, deadline time.Time, cancel <-c ...@@ -357,15 +357,9 @@ func (fd *netFD) connect(la, ra syscall.Sockaddr, deadline time.Time, cancel <-c
go func() { go func() {
select { select {
case <-cancel: case <-cancel:
// TODO(bradfitz,brainman): cancel the dial operation // Force the runtime's poller to immediately give
// somehow. Brad doesn't know Windows but is going to // up waiting for writability.
// try this: fd.setWriteDeadline(aLongTimeAgo)
if canCancelIO {
syscall.CancelIoEx(o.fd.sysfd, &o.o)
} else {
wsrv.req <- ioSrvReq{o, nil}
<-o.errc
}
case <-done: case <-done:
} }
}() }()
......
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