提交 0da8f78c 编写于 作者: A allwin

8012923: [parfait] File Descriptor Leak in jdk/src/windows/demo/jvmti/hprof/hprof_md.c

Reviewed-by: chegar, sla, sspitsyn, mgronlun
上级 b39b6f8a
...@@ -82,9 +82,6 @@ md_connect(char *hostname, unsigned short port) ...@@ -82,9 +82,6 @@ md_connect(char *hostname, unsigned short port)
struct sockaddr_in s; struct sockaddr_in s;
int fd; int fd;
/* create a socket */
fd = (int)socket(AF_INET, SOCK_STREAM, 0);
/* find remote host's addr from name */ /* find remote host's addr from name */
if ((hentry = gethostbyname(hostname)) == NULL) { if ((hentry = gethostbyname(hostname)) == NULL) {
return -1; return -1;
...@@ -97,8 +94,15 @@ md_connect(char *hostname, unsigned short port) ...@@ -97,8 +94,15 @@ md_connect(char *hostname, unsigned short port)
s.sin_port = htons(port); s.sin_port = htons(port);
s.sin_family = AF_INET; s.sin_family = AF_INET;
/* create a socket */
fd = (int)socket(AF_INET, SOCK_STREAM, 0);
if (INVALID_SOCKET == fd) {
return 0;
}
/* now try connecting */ /* now try connecting */
if (-1 == connect(fd, (struct sockaddr*)&s, sizeof(s))) { if (SOCKET_ERROR == connect(fd, (struct sockaddr*)&s, sizeof(s))) {
closesocket(fd);
return 0; return 0;
} }
return fd; return fd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册