diff options
author | Alex Brainman <alex.brainman@gmail.com> | 2015-12-17 10:03:13 +1100 |
---|---|---|
committer | Alex Brainman <alex.brainman@gmail.com> | 2015-12-16 23:51:38 +0000 |
commit | f33f9b2ceeaa96df617871dee77fd52e94e4fc3e (patch) | |
tree | 82ae849ab14565fd9c09c9fb469beac5920b96f4 | |
parent | a766d8e59c2c43b4c6795404d303b64b9fe69a0f (diff) | |
download | go-f33f9b2ceeaa96df617871dee77fd52e94e4fc3e.tar.gz go-f33f9b2ceeaa96df617871dee77fd52e94e4fc3e.zip |
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/17920
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
-rw-r--r-- | src/net/fd_windows.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/net/fd_windows.go b/src/net/fd_windows.go index de6a9cbf58..fd50d772d6 100644 --- a/src/net/fd_windows.go +++ b/src/net/fd_windows.go @@ -357,15 +357,9 @@ func (fd *netFD) connect(la, ra syscall.Sockaddr, deadline time.Time, cancel <-c go func() { select { case <-cancel: - // TODO(bradfitz,brainman): cancel the dial operation - // somehow. Brad doesn't know Windows but is going to - // try this: - if canCancelIO { - syscall.CancelIoEx(o.fd.sysfd, &o.o) - } else { - wsrv.req <- ioSrvReq{o, nil} - <-o.errc - } + // Force the runtime's poller to immediately give + // up waiting for writability. + fd.setWriteDeadline(aLongTimeAgo) case <-done: } }() |