Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
6c51f9a0
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看板
提交
6c51f9a0
编写于
1月 10, 2011
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
Reviewed-by: chegar
上级
0ba2e05f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
86 deletion
+38
-86
make/java/nio/Makefile
make/java/nio/Makefile
+1
-1
src/solaris/native/sun/nio/ch/FileChannelImpl.c
src/solaris/native/sun/nio/ch/FileChannelImpl.c
+37
-85
未找到文件。
make/java/nio/Makefile
浏览文件 @
6c51f9a0
...
...
@@ -296,7 +296,7 @@ ifeq ($(PLATFORM), linux)
OTHER_LDLIBS
+=
-L
$(LIBDIR)
/
$(LIBARCH)
-ljava
-lnet
-lpthread
-ldl
endif
ifeq
($(PLATFORM), solaris)
OTHER_LDLIBS
+=
$(JVMLIB)
$(LIBSOCKET)
-lposix4
-ldl
\
OTHER_LDLIBS
+=
$(JVMLIB)
$(LIBSOCKET)
-lposix4
-ldl
-lsendfile
\
-L
$(LIBDIR)
/
$(LIBARCH)
-ljava
-lnet
endif
# PLATFORM
...
...
src/solaris/native/sun/nio/ch/FileChannelImpl.c
浏览文件 @
6c51f9a0
...
...
@@ -35,48 +35,17 @@
#include "nio_util.h"
#include <dlfcn.h>
static
jfieldID
chan_fd
;
/* jobject 'fd' in sun.io.FileChannelImpl */
#ifdef __solaris__
typedef
struct
sendfilevec64
{
int
sfv_fd
;
/* input fd */
uint_t
sfv_flag
;
/* Flags. see below */
off64_t
sfv_off
;
/* offset to start reading from */
size_t
sfv_len
;
/* amount of data */
}
sendfilevec_t
;
/* Function pointer for sendfilev on Solaris 8+ */
typedef
ssize_t
sendfile_func
(
int
fildes
,
const
struct
sendfilevec64
*
vec
,
int
sfvcnt
,
size_t
*
xferred
);
sendfile_func
*
my_sendfile_func
=
NULL
;
#endif
#ifdef __linux__
#if defined(__linux__) || defined(__solaris__)
#include <sys/sendfile.h>
/* Function pointer for sendfile64 on Linux 2.6 (and newer 2.4 kernels) */
typedef
ssize_t
sendfile64_func
(
int
out_fd
,
int
in_fd
,
off64_t
*
offset
,
size_t
count
);
sendfile64_func
*
my_sendfile64_func
=
NULL
;
#endif
static
jfieldID
chan_fd
;
/* jobject 'fd' in sun.io.FileChannelImpl */
JNIEXPORT
jlong
JNICALL
Java_sun_nio_ch_FileChannelImpl_initIDs
(
JNIEnv
*
env
,
jclass
clazz
)
{
jlong
pageSize
=
sysconf
(
_SC_PAGESIZE
);
chan_fd
=
(
*
env
)
->
GetFieldID
(
env
,
clazz
,
"fd"
,
"Ljava/io/FileDescriptor;"
);
#ifdef __solaris__
if
(
dlopen
(
"/usr/lib/libsendfile.so.1"
,
RTLD_GLOBAL
|
RTLD_LAZY
)
!=
NULL
)
{
my_sendfile_func
=
(
sendfile_func
*
)
dlsym
(
RTLD_DEFAULT
,
"sendfilev64"
);
}
#endif
#ifdef __linux__
my_sendfile64_func
=
(
sendfile64_func
*
)
dlsym
(
RTLD_DEFAULT
,
"sendfile64"
);
#endif
return
pageSize
;
}
...
...
@@ -178,22 +147,9 @@ Java_sun_nio_ch_FileChannelImpl_transferTo0(JNIEnv *env, jobject this,
jlong
position
,
jlong
count
,
jint
dstFD
)
{
#ifdef __linux__
jlong
max
=
(
jlong
)
java_lang_Integer_MAX_VALUE
;
jlong
n
;
if
(
my_sendfile64_func
==
NULL
)
{
off_t
offset
;
if
(
position
>
max
)
return
IOS_UNSUPPORTED_CASE
;
if
(
count
>
max
)
count
=
max
;
offset
=
(
off_t
)
position
;
n
=
sendfile
(
dstFD
,
srcFD
,
&
offset
,
(
size_t
)
count
);
}
else
{
off64_t
offset
=
(
off64_t
)
position
;
n
=
(
*
my_sendfile64_func
)(
dstFD
,
srcFD
,
&
offset
,
(
size_t
)
count
);
}
#if defined(__linux__)
off64_t
offset
=
(
off64_t
)
position
;
jlong
n
=
sendfile64
(
dstFD
,
srcFD
,
&
offset
,
(
size_t
)
count
);
if
(
n
<
0
)
{
if
(
errno
==
EAGAIN
)
return
IOS_UNAVAILABLE
;
...
...
@@ -206,41 +162,37 @@ Java_sun_nio_ch_FileChannelImpl_transferTo0(JNIEnv *env, jobject this,
return
IOS_THROWN
;
}
return
n
;
#endif
#ifdef __solaris__
if
(
my_sendfile_func
==
NULL
)
{
return
IOS_UNSUPPORTED
;
}
else
{
sendfilevec_t
sfv
;
size_t
numBytes
=
0
;
jlong
result
;
sfv
.
sfv_fd
=
srcFD
;
sfv
.
sfv_flag
=
0
;
sfv
.
sfv_off
=
(
off64_t
)
position
;
sfv
.
sfv_len
=
count
;
result
=
(
*
my_sendfile_func
)(
dstFD
,
&
sfv
,
1
,
&
numBytes
);
/* Solaris sendfilev() will return -1 even if some bytes have been
* transferred, so we check numBytes first.
*/
if
(
numBytes
>
0
)
return
numBytes
;
if
(
result
<
0
)
{
if
(
errno
==
EAGAIN
)
return
IOS_UNAVAILABLE
;
if
(
errno
==
EOPNOTSUPP
)
return
IOS_UNSUPPORTED_CASE
;
if
((
errno
==
EINVAL
)
&&
((
ssize_t
)
count
>=
0
))
return
IOS_UNSUPPORTED_CASE
;
if
(
errno
==
EINTR
)
return
IOS_INTERRUPTED
;
JNU_ThrowIOExceptionWithLastError
(
env
,
"Transfer failed"
);
return
IOS_THROWN
;
}
return
result
;
#elif defined (__solaris__)
sendfilevec64_t
sfv
;
size_t
numBytes
=
0
;
jlong
result
;
sfv
.
sfv_fd
=
srcFD
;
sfv
.
sfv_flag
=
0
;
sfv
.
sfv_off
=
(
off64_t
)
position
;
sfv
.
sfv_len
=
count
;
result
=
sendfilev64
(
dstFD
,
&
sfv
,
1
,
&
numBytes
);
/* Solaris sendfilev() will return -1 even if some bytes have been
* transferred, so we check numBytes first.
*/
if
(
numBytes
>
0
)
return
numBytes
;
if
(
result
<
0
)
{
if
(
errno
==
EAGAIN
)
return
IOS_UNAVAILABLE
;
if
(
errno
==
EOPNOTSUPP
)
return
IOS_UNSUPPORTED_CASE
;
if
((
errno
==
EINVAL
)
&&
((
ssize_t
)
count
>=
0
))
return
IOS_UNSUPPORTED_CASE
;
if
(
errno
==
EINTR
)
return
IOS_INTERRUPTED
;
JNU_ThrowIOExceptionWithLastError
(
env
,
"Transfer failed"
);
return
IOS_THROWN
;
}
return
result
;
#else
return
IOS_UNSUPPORTED_CASE
;
#endif
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录