提交 0241f76e 编写于 作者: I igerasim

7010989: Duplicate closure of file descriptors leads to unexpected and incorrect closure of sockets

Reviewed-by: chegar
上级 9c508616
......@@ -489,6 +489,9 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
}
}
} else {
/* NET_BindV6() closes both sockets upon a failure */
(*env)->SetObjectField(env, this, pdsi_fdID, NULL);
(*env)->SetObjectField(env, this, pdsi_fd1ID, NULL);
NET_ThrowCurrent (env, "Cannot bind");
return;
}
......
......@@ -467,6 +467,10 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this,
(*env)->SetIntField(env, fd1Obj, IO_fd_fdID, fd1);
}
}
} else {
/* NET_BindV6() closes both sockets upon a failure */
(*env)->SetObjectField(env, this, psi_fdID, NULL);
(*env)->SetObjectField(env, this, psi_fd1ID, NULL);
}
} else {
rv = NET_WinBind(fd, (struct sockaddr *)&him, len, exclBind);
......
......@@ -627,7 +627,7 @@ void dumpAddr (char *str, void *addr) {
* and returns SOCKET_ERROR. Used in NET_BindV6 only.
*/
#define CLOSE_SOCKETS_AND_RETURN { \
#define CLOSE_SOCKETS_AND_RETURN do { \
if (fd != -1) { \
closesocket (fd); \
fd = -1; \
......@@ -646,7 +646,7 @@ void dumpAddr (char *str, void *addr) {
} \
b->ipv4_fd = b->ipv6_fd = -1; \
return SOCKET_ERROR; \
}
} while(0)
/*
* if ipv6 is available, call NET_BindV6 to bind to the required address/port.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册