-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8308593: Add Keepalive Extended Socket Options Support for Windows #14232
Conversation
👋 Welcome back tkyc! A progress list of the required criteria for merging this PR into |
Webrevs
|
I think you may have missed my comment in the JBS issue where I asked about the semantics of SIO_KEEPALIVE_VALS and whether we could implement TCP_KEEPIDLE and TCP_KEEPINTERVAL on Windows by knowing what the defaults are. The proposal that you have here is a new Windows specific and JDK-specific socket option that requires a lot of thinking about before going that route. |
Apologies, I was talking to my liaison on what's the appropriate way to communicate (as I don't have a JBS account). Let me know if it's alright to discuss things here. Thanks for the quick reply on your thoughts.
I had similar thoughts as well, that this implementation was more of a "last resort". I've had other ideas of ways to go about this that I'll mention below, but there were some contentions and so this implementation was the most straightforward to do to get something working in order to have open dialog. But yeah, absolutely agree on more discussion.
Yes, that's correct. SIO_KEEPALIVE_VALS is the Windows equivalent of setting the keep alive values on a per socket basis (only difference is that both are set at the same time).
So officially, the system-wide default keep alive idle and interval for Windows is 2hrs and 1s respectively. I also thought of using default values, but the issue is this:
But we can get around this by keeping track of the current set keepAlive values. However, another issue is that the default values are not always 2hrs and 1s, it's possible that it could be different.
However, we can't keep track of the current keep alive values in Edit: Just saw your most recent comment on the JBS ticket. I'll move the discussion to the net-dev mailing list. |
In the discussion on net-dev/nio-dev, Daniel Jeliński pointed out that Windows does have TCP_KEEPIDLE and TCP_KEEPINTVL since Windows 10 version 1709. So I assume this PR can be closed or re-returned to draft while the implementation changes are developed to make use of these socket options. |
a785898
to
2ada220
Compare
/label remove nio |
@AlanBateman |
HI, just wondering if there's anything needed from me further (the related threads have been inactive for some time). |
The original to use TCP_SIO_KEEPALIVE was problematic for several reasons, changing it to use TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL after finding out that these socket options are supported on Windows is good. So I think we should review and include this. |
The changes to I see that the JNI code is updated to use In the meantime, could you please update the copyright year on both these changed files to |
Hello Terry,
The existing |
Never mind, I see now the code is implementing the already existing options now from Linux/Macos. |
I think it is right to change the |
Thanks all for the review so far. I'll make the copyright year changes. So, the consensus for the |
I think Michael means that you can keep the |
Right. That's what I meant. The change looks good to me, but I might run the patch through the test system here to see how it works with the existing tests in this area and the change above doesn't cause any issues. |
Right, WSAGetLastError should be used with Windows Sockets, not errno. |
There was a problem hiding this 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, subject to copyright update.
@tkyc This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 412 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@Michael-Mc-Mahon, @djelinski, @vyommani) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Awesome, thanks all for the review. |
/integrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Verified that test/jdk/java/net/SocketOption/TcpKeepAliveTest.java
is able to set and get the options on Windows 11 as expected.
On a side note, the test could be more verbose - currently it is not clear if the test passes because the options worked or because they were unsupported. But that's preexisting and not much of a problem anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for doing changes for other platforms as well. Latest changes looks OK to me.
It looks like you need to type the "integrate" command again, after the last change. We can sponsor it then. |
Agreed. When I tested this PR in our CI, I had to locally update |
Thanks all. |
/integrate |
/sponsor |
Going to push as commit f3ade38.
Your commit was automatically rebased without conflicts. |
@Michael-Mc-Mahon @tkyc Pushed as commit f3ade38. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi, this issue is marked as needing a release note but none has been produced. |
@dfuch Sorry I missed that step. I'll add a release note according to your linked instructions. |
Just a heads up, incase things move slow. Since I don't have a JBS account, I'm just waiting on some help from my msft liaison to help add the release note to the ticket. |
Hello, a release note was added to the ticket awhile ago. Let me know if there's anything else I need to do or correct. Thanks again. |
Thanks Terry @tkyc. I have made some updates and marked it DELIVERED. Can you double check that everything still looks good? |
@dfuch LGTM. Thanks for the quick update Daniel. |
The PR adds support for the keepalive extended socket options on Windows. For TCP_KEEPIDLE and TCP_KEEPINTVL, these options are supported starting from Windows 10 version 1709. TCP_KEEPCNT is supported starting from Windows 10 version 1703. Information on these socket options can be found here.
I've also corrected the
handleError()
function. On Windows, the error needs to be retrieved usingWSAGetLastError()
and error codes are prefixed with "WSA". Information on this can be found here.No new tests were added as the existing tests should cover this.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14232/head:pull/14232
$ git checkout pull/14232
Update a local copy of the PR:
$ git checkout pull/14232
$ git pull https://git.openjdk.org/jdk.git pull/14232/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14232
View PR using the GUI difftool:
$ git pr show -t 14232
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14232.diff
Webrev
Link to Webrev Comment