changeset 51589:9aa7ac61e68c

8210147: adjust some WSAGetLastError usages in windows network coding Reviewed-by: clanger, stuefe
author mbaesken
date Wed, 29 Aug 2018 10:11:51 +0200
parents f36e08f052b1
children 3aaf039a3636
files src/java.base/windows/native/libnet/Inet4AddressImpl.c src/java.base/windows/native/libnet/Inet6AddressImpl.c src/java.base/windows/native/libnet/SocketInputStream.c
diffstat 3 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Thu Aug 30 09:12:07 2018 +0200
+++ b/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Wed Aug 29 10:11:51 2018 +0200
@@ -326,7 +326,7 @@
     ReplyBuffer = (VOID *)malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
-        NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory");
+        NET_ThrowNew(env, -1, "Unable to allocate memory");
         return JNI_FALSE;
     }
 
--- a/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Thu Aug 30 09:12:07 2018 +0200
+++ b/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Wed Aug 29 10:11:51 2018 +0200
@@ -396,7 +396,7 @@
     ReplyBuffer = (VOID *)malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
-        NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory");
+        NET_ThrowNew(env, -1, "Unable to allocate memory");
         return JNI_FALSE;
     }
 
--- a/src/java.base/windows/native/libnet/SocketInputStream.c	Thu Aug 30 09:12:07 2018 +0200
+++ b/src/java.base/windows/native/libnet/SocketInputStream.c	Wed Aug 29 10:11:51 2018 +0200
@@ -122,12 +122,13 @@
         (*env)->SetByteArrayRegion(env, data, off, nread, (jbyte *)bufP);
     } else {
         if (nread < 0) {
+            int err = WSAGetLastError();
             // Check if the socket has been closed since we last checked.
             // This could be a reason for recv failing.
             if ((*env)->GetIntField(env, fdObj, IO_fd_fdID) == -1) {
                 JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
             } else {
-                switch (WSAGetLastError()) {
+                switch (err) {
                     case WSAEINTR:
                         JNU_ThrowByName(env, "java/net/SocketException",
                             "socket closed");