Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: call WSAGetLastError on Windows #38134

Closed
networkimprov opened this issue Mar 28, 2020 · 2 comments
Closed

net: call WSAGetLastError on Windows #38134

networkimprov opened this issue Mar 28, 2020 · 2 comments
Labels

Comments

@networkimprov
Copy link

@networkimprov networkimprov commented Mar 28, 2020

Winsock API calls don't set errno, instead you call WSAGetLastError(). It looks like Go doesn't. Have I missed something?

https://docs.microsoft.com/en-us/windows/win32/winsock/error-codes-errno-h-errno-and-wsagetlasterror-2

This affects net.isConnError() and a fix for #35131.

func isConnError(err error) bool {
        if se, ok := err.(syscall.Errno); ok {
                return se == syscall.WSAECONNRESET || se == syscall.WSAECONNABORTED
        }
        return false

cc @bcmills @ianlancetaylor @iWdGo @alexbrainman @zx2c4 @mattn @jstarks
@gopherbot add OS-Windows

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Mar 28, 2020

WSAGetLastError is just a synonym for GetLastError. At least on amd64 the Go runtime cheats by inlining GetLastError to just load directly from %gs. See asmstdcall and getlasterror in runtime/sys_windows_amd64.s.

If we get this wrong somewhere lets look at that specific case, but I'm going to close this general issue because there shouldn't be a general problem here.

@networkimprov
Copy link
Author

@networkimprov networkimprov commented Mar 28, 2020

Ah, sorry; that's not mentioned in the MS docs, but described in
https://stackoverflow.com/questions/15586224/is-wsagetlasterror-just-an-alias-for-getlasterror

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.