RFR: JDK-8317603: provide handleSocketErrorWithMessage in windows Net.c for extended exception messages [v3]

Matthias Baesken mbaesken at openjdk.org
Mon Oct 9 10:31:02 UTC 2023


On Sat, 7 Oct 2023 12:41:31 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> Moving to using NET_ThrowNew is okay but it creates inconsistencies that have to be fixed. I think this PR will go through a few iterations.
> 
> Some background here is that the socket code no longer exists in libnet/net.dll and at some point we need to do some cleanup and refactoring so that libnio does not have libnet as a dependency (if you go through the JBS issue you'll see a number of startup/first-use issues caused by this dependency). We don't have to do this as part of this PR of course but it provides some context.
> 
> For this PR, the issue with changing the specific functions to use NET_ThrowNet is that handleSocketError is left in place for DatagramChannelImpl.c, IOUtil.c and UnixDomainSocket.c. We shouldn't do that. We either replace usages (and remove handleSocketError) or change the existing function to take an additional message.

Okay, let's remove then the usages in the files you mentioned.

> src/java.base/windows/native/libnio/ch/Net.c line 559:
> 
>> 557:     int n = setGroupSourceReqOption(env, fdo, opt, group, index, source);
>> 558:     if (n == SOCKET_ERROR) {
>> 559:         NET_ThrowNew(env, WSAGetLastError(), "setsockopt with group source request");
> 
> That message looks odd, I think you want "setsocketopt to block or unblock source".

Thanks, I adjusted the message.

> src/java.base/windows/native/libnio/ch/Net.c line 638:
> 
>> 636:     int count = 0;
>> 637:     if (NET_SocketAvailable(fdval(env, fdo), &count) != 0) {
>> 638:         NET_ThrowNew(env, WSAGetLastError(), "socket availability check");
> 
> This should be "ioctlsocket", not ""socket availability check". Better still would be to just replace the usage of NET_SocketAvailable to use ioctlsocket directly as we will eventually remove NET_SocketAvailable.

okay then let's use  ioctlsocket . We could  completely remove  NET_SocketAvailable.  but in a follow up.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16057#issuecomment-1752712706
PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1350097325
PR Review Comment: https://git.openjdk.org/jdk/pull/16057#discussion_r1350098133


More information about the nio-dev mailing list