Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
59bb9bb5
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
59bb9bb5
编写于
4月 23, 2018
作者:
C
clanger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8201369: Inet4AddressImpl_getLocalHostName reverse lookup on Solaris only
Reviewed-by: clanger, chegar Contributed-by: sshamaia@in.ibm.com
上级
cb0ed89e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
53 deletion
+38
-53
src/solaris/native/java/net/Inet4AddressImpl.c
src/solaris/native/java/net/Inet4AddressImpl.c
+21
-23
src/solaris/native/java/net/Inet6AddressImpl.c
src/solaris/native/java/net/Inet6AddressImpl.c
+17
-30
未找到文件。
src/solaris/native/java/net/Inet4AddressImpl.c
浏览文件 @
59bb9bb5
...
...
@@ -67,38 +67,36 @@ extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolea
*/
JNIEXPORT
jstring
JNICALL
Java_java_net_Inet4AddressImpl_getLocalHostName
(
JNIEnv
*
env
,
jobject
this
)
{
char
hostname
[
NI_MAXHOST
+
1
];
char
hostname
[
NI_MAXHOST
+
1
];
hostname
[
0
]
=
'\0'
;
if
(
JVM_GetHostName
(
hostname
,
NI_MAXHOST
))
{
/* Something went wrong, maybe networking is not setup? */
strcpy
(
hostname
,
"localhost"
);
#if defined(__solaris__)
}
else
{
// try to resolve hostname via nameservice
// if it is known but getnameinfo fails, hostname will still be the
// value from gethostname
struct
addrinfo
hints
,
*
res
;
int
error
;
// make sure string is null-terminated
hostname
[
NI_MAXHOST
]
=
'\0'
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_flags
=
AI_CANONNAME
;
hints
.
ai_family
=
AF_UNSPEC
;
error
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
res
);
if
(
error
==
0
)
{
/* host is known to name service */
error
=
getnameinfo
(
res
->
ai_addr
,
res
->
ai_addrlen
,
hostname
,
NI_MAXHOST
,
NULL
,
0
,
NI_NAMEREQD
);
/* if getnameinfo fails hostname is still the value
from gethostname */
hints
.
ai_family
=
AF_INET
;
if
(
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
res
)
==
0
)
{
getnameinfo
(
res
->
ai_addr
,
res
->
ai_addrlen
,
hostname
,
NI_MAXHOST
,
NULL
,
0
,
NI_NAMEREQD
);
freeaddrinfo
(
res
);
}
}
#else
}
else
{
// make sure string is null-terminated
hostname
[
NI_MAXHOST
]
=
'\0'
;
}
#endif
return
(
*
env
)
->
NewStringUTF
(
env
,
hostname
);
}
...
...
src/solaris/native/java/net/Inet6AddressImpl.c
浏览文件 @
59bb9bb5
...
...
@@ -66,49 +66,36 @@
*/
JNIEXPORT
jstring
JNICALL
Java_java_net_Inet6AddressImpl_getLocalHostName
(
JNIEnv
*
env
,
jobject
this
)
{
char
hostname
[
NI_MAXHOST
+
1
];
char
hostname
[
NI_MAXHOST
+
1
];
hostname
[
0
]
=
'\0'
;
if
(
JVM_GetHostName
(
hostname
,
sizeof
(
hostname
)))
{
/* Something went wrong, maybe networking is not setup? */
strcpy
(
hostname
,
"localhost"
);
}
else
{
// ensure null-terminated
hostname
[
NI_MAXHOST
]
=
'\0'
;
/* Solaris doesn't want to give us a fully qualified domain name.
* We do a reverse lookup to try and get one. This works
* if DNS occurs before NIS in /etc/resolv.conf, but fails
* if NIS comes first (it still gets only a partial name).
* We use thread-safe system calls.
*/
#if defined(__solaris__) && defined(AF_INET6)
}
else
{
// try to resolve hostname via nameservice
// if it is known but getnameinfo fails, hostname will still be the
// value from gethostname
struct
addrinfo
hints
,
*
res
;
int
error
;
// make sure string is null-terminated
hostname
[
NI_MAXHOST
]
=
'\0'
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_flags
=
AI_CANONNAME
;
hints
.
ai_family
=
AF_UNSPEC
;
error
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
res
);
if
(
error
==
0
)
{
/* host is known to name service */
error
=
getnameinfo
(
res
->
ai_addr
,
res
->
ai_addrlen
,
hostname
,
NI_MAXHOST
,
NULL
,
0
,
NI_NAMEREQD
);
/* if getnameinfo fails hostname is still the value
from gethostname */
if
(
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
res
)
==
0
)
{
getnameinfo
(
res
->
ai_addr
,
res
->
ai_addrlen
,
hostname
,
NI_MAXHOST
,
NULL
,
0
,
NI_NAMEREQD
);
freeaddrinfo
(
res
);
}
#endif
}
#else
}
else
{
// make sure string is null-terminated
hostname
[
NI_MAXHOST
]
=
'\0'
;
}
#endif
return
(
*
env
)
->
NewStringUTF
(
env
,
hostname
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录