8210147: adjust some WSAGetLastError usages in windows network coding

Reviewed-by: clanger, stuefe
This commit is contained in:
Matthias Baesken 2018-08-29 10:11:51 +02:00
parent af545969be
commit 149be4bad1
3 changed files with 4 additions and 3 deletions

View File

@ -326,7 +326,7 @@ ping4(JNIEnv *env, HANDLE hIcmpFile, SOCKETADDRESS *sa,
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;
}

View File

@ -396,7 +396,7 @@ ping6(JNIEnv *env, HANDLE hIcmpFile, SOCKETADDRESS *sa,
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;
}

View File

@ -122,12 +122,13 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
(*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");