8210147: adjust some WSAGetLastError usages in windows network coding
Reviewed-by: clanger, stuefe
This commit is contained in:
parent
af545969be
commit
149be4bad1
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user