提交 4e76c5b3 编写于 作者: M mbaesken

8210147: adjust some WSAGetLastError usages in windows network coding

Reviewed-by: clanger, stuefe
上级 d8fe8e9b
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册