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

Simplify Windows debugger socket setup #10212

Merged
merged 4 commits into from Feb 23, 2021

Conversation

MisterDA
Copy link
Contributor

Don't use SO_OPENTYPE in Windows debugger. It was probably deprecated
at some point, and the same feature can be achieved with WSASocket.

The documentation reads (about SO_OPENTYPE):

Once set, affects whether subsequent sockets that are created will
be non-overlapped. The possible values for this option are
SO_SYNCHRONOUS_ALERT and SO_SYNCHRONOUS_NONALERT. This option should
not be used. Instead use the WSASocket function and leave the
WSA_FLAG_OVERLAPPED bit in the dwFlags parameter turned off.

https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options

This allows to merge Windows-specific code and to remove all the
sockopt related code. Keeping the _open_osfhandle error is not
necessary.

Don't use SO_OPENTYPE in Windows debugger. It was probably deprecated
at some point, and the same feature can be achieved with WSASocket.

The documentation reads (about SO_OPENTYPE):

> Once set, affects whether subsequent sockets that are created will
> be non-overlapped. The possible values for this option are
> SO_SYNCHRONOUS_ALERT and SO_SYNCHRONOUS_NONALERT. This option should
> not be used. Instead use the WSASocket function and leave the
> WSA_FLAG_OVERLAPPED bit in the dwFlags parameter turned off.

https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options

This allows to merge Windows-specific code and to remove all the
sockopt related code. Keeping the _open_osfhandle error is not
necessary.

No change entry needed
Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. WSAsocket was introduced in Vista and Server 2003, after the original code was written. It's probably OK to use it, provided we update the minimal Windows requirements in README.win32.doc.

Error reporting is not quite right, but it's no worse than in the old code, see comment below.

runtime/debugger.c Outdated Show resolved Hide resolved
@xavierleroy
Copy link
Contributor

I took the liberty to push a tentative improvement to your branch. Please comment! And let's see what CI says about it.

runtime/debugger.c Outdated Show resolved Hide resolved
@xavierleroy
Copy link
Contributor

@MisterDA and anyone else who would care to comment: are you OK with my proposed change to error handling? If so I'll merge this PR.

@MisterDA
Copy link
Contributor Author

I'm ok with the proposed change.

@xavierleroy xavierleroy merged commit 7300f88 into ocaml:trunk Feb 23, 2021
@xavierleroy
Copy link
Contributor

Precheck CI was positive. I added a Changes entry and merged.

garrigue pushed a commit to garrigue/ocaml that referenced this pull request Mar 3, 2021
Don't use SO_OPENTYPE in Windows debugger. It was probably deprecated
at some point, and the same feature can be achieved with WSASocket.

The documentation reads (about SO_OPENTYPE):

> Once set, affects whether subsequent sockets that are created will
> be non-overlapped. The possible values for this option are
> SO_SYNCHRONOUS_ALERT and SO_SYNCHRONOUS_NONALERT. This option should
> not be used. Instead use the WSASocket function and leave the
> WSA_FLAG_OVERLAPPED bit in the dwFlags parameter turned off.

https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options

This allows to merge Windows-specific code and to remove all the
sockopt related code. Keeping the _open_osfhandle error is not
necessary.

Also:  improve "cannot connect" error reporting under Windows

Co-authored-by: Xavier Leroy <xavier.leroy@college-de-france.fr>
smuenzel pushed a commit to smuenzel/ocaml that referenced this pull request Mar 30, 2021
Don't use SO_OPENTYPE in Windows debugger. It was probably deprecated
at some point, and the same feature can be achieved with WSASocket.

The documentation reads (about SO_OPENTYPE):

> Once set, affects whether subsequent sockets that are created will
> be non-overlapped. The possible values for this option are
> SO_SYNCHRONOUS_ALERT and SO_SYNCHRONOUS_NONALERT. This option should
> not be used. Instead use the WSASocket function and leave the
> WSA_FLAG_OVERLAPPED bit in the dwFlags parameter turned off.

https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options

This allows to merge Windows-specific code and to remove all the
sockopt related code. Keeping the _open_osfhandle error is not
necessary.

Also:  improve "cannot connect" error reporting under Windows

Co-authored-by: Xavier Leroy <xavier.leroy@college-de-france.fr>
@MisterDA MisterDA deleted the debugger-winsock2 branch April 6, 2023 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants