author | alanb |
Fri, 23 Mar 2018 14:18:18 +0000 | |
changeset 49290 | 07779973cbe2 |
parent 47428 | d72d7d55c765 |
child 49897 | 117501815bed |
permissions | -rw-r--r-- |
2 | 1 |
/* |
47009
ed227a8f92fb
8186707: Remove libnio FileChannelImpl native close0() function
bpb
parents:
27937
diff
changeset
|
2 |
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include "jni.h" |
|
27 |
#include "jni_util.h" |
|
28 |
#include "jvm.h" |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
29 |
#include "jvm_md.h" |
2 | 30 |
#include "jlong.h" |
31 |
#include <sys/mman.h> |
|
32 |
#include <sys/stat.h> |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
33 |
#include <fcntl.h> |
2 | 34 |
#include "sun_nio_ch_FileChannelImpl.h" |
35 |
#include "java_lang_Integer.h" |
|
36 |
#include "nio.h" |
|
37 |
#include "nio_util.h" |
|
38 |
#include <dlfcn.h> |
|
39 |
||
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
40 |
#if defined(__linux__) || defined(__solaris__) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
41 |
#include <sys/sendfile.h> |
24575
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
42 |
#elif defined(_AIX) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
43 |
#include <sys/socket.h> |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
44 |
#elif defined(_ALLBSD_SOURCE) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
45 |
#include <sys/types.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
46 |
#include <sys/socket.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
47 |
#include <sys/uio.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
48 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
49 |
#define lseek64 lseek |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
50 |
#define mmap64 mmap |
2 | 51 |
#endif |
52 |
||
47428 | 53 |
static jfieldID chan_fd; /* jobject 'fd' in sun.nio.ch.FileChannelImpl */ |
2 | 54 |
|
55 |
JNIEXPORT jlong JNICALL |
|
56 |
Java_sun_nio_ch_FileChannelImpl_initIDs(JNIEnv *env, jclass clazz) |
|
57 |
{ |
|
58 |
jlong pageSize = sysconf(_SC_PAGESIZE); |
|
59 |
chan_fd = (*env)->GetFieldID(env, clazz, "fd", "Ljava/io/FileDescriptor;"); |
|
60 |
return pageSize; |
|
61 |
} |
|
62 |
||
63 |
static jlong |
|
64 |
handle(JNIEnv *env, jlong rv, char *msg) |
|
65 |
{ |
|
66 |
if (rv >= 0) |
|
67 |
return rv; |
|
68 |
if (errno == EINTR) |
|
69 |
return IOS_INTERRUPTED; |
|
70 |
JNU_ThrowIOExceptionWithLastError(env, msg); |
|
71 |
return IOS_THROWN; |
|
72 |
} |
|
73 |
||
74 |
||
75 |
JNIEXPORT jlong JNICALL |
|
76 |
Java_sun_nio_ch_FileChannelImpl_map0(JNIEnv *env, jobject this, |
|
77 |
jint prot, jlong off, jlong len) |
|
78 |
{ |
|
79 |
void *mapAddress = 0; |
|
80 |
jobject fdo = (*env)->GetObjectField(env, this, chan_fd); |
|
81 |
jint fd = fdval(env, fdo); |
|
82 |
int protections = 0; |
|
83 |
int flags = 0; |
|
84 |
||
85 |
if (prot == sun_nio_ch_FileChannelImpl_MAP_RO) { |
|
86 |
protections = PROT_READ; |
|
87 |
flags = MAP_SHARED; |
|
88 |
} else if (prot == sun_nio_ch_FileChannelImpl_MAP_RW) { |
|
89 |
protections = PROT_WRITE | PROT_READ; |
|
90 |
flags = MAP_SHARED; |
|
91 |
} else if (prot == sun_nio_ch_FileChannelImpl_MAP_PV) { |
|
92 |
protections = PROT_WRITE | PROT_READ; |
|
93 |
flags = MAP_PRIVATE; |
|
94 |
} |
|
95 |
||
96 |
mapAddress = mmap64( |
|
97 |
0, /* Let OS decide location */ |
|
98 |
len, /* Number of bytes to map */ |
|
99 |
protections, /* File permissions */ |
|
100 |
flags, /* Changes are shared */ |
|
101 |
fd, /* File descriptor of mapped file */ |
|
102 |
off); /* Offset into file */ |
|
103 |
||
104 |
if (mapAddress == MAP_FAILED) { |
|
105 |
if (errno == ENOMEM) { |
|
106 |
JNU_ThrowOutOfMemoryError(env, "Map failed"); |
|
107 |
return IOS_THROWN; |
|
108 |
} |
|
109 |
return handle(env, -1, "Map failed"); |
|
110 |
} |
|
111 |
||
112 |
return ((jlong) (unsigned long) mapAddress); |
|
113 |
} |
|
114 |
||
115 |
||
116 |
JNIEXPORT jint JNICALL |
|
117 |
Java_sun_nio_ch_FileChannelImpl_unmap0(JNIEnv *env, jobject this, |
|
118 |
jlong address, jlong len) |
|
119 |
{ |
|
120 |
void *a = (void *)jlong_to_ptr(address); |
|
121 |
return handle(env, |
|
122 |
munmap(a, (size_t)len), |
|
123 |
"Unmap failed"); |
|
124 |
} |
|
125 |
||
126 |
||
127 |
JNIEXPORT jlong JNICALL |
|
128 |
Java_sun_nio_ch_FileChannelImpl_position0(JNIEnv *env, jobject this, |
|
129 |
jobject fdo, jlong offset) |
|
130 |
{ |
|
131 |
jint fd = fdval(env, fdo); |
|
132 |
jlong result = 0; |
|
133 |
||
134 |
if (offset < 0) { |
|
135 |
result = lseek64(fd, 0, SEEK_CUR); |
|
136 |
} else { |
|
137 |
result = lseek64(fd, offset, SEEK_SET); |
|
138 |
} |
|
139 |
return handle(env, result, "Position failed"); |
|
140 |
} |
|
141 |
||
142 |
||
143 |
JNIEXPORT jlong JNICALL |
|
144 |
Java_sun_nio_ch_FileChannelImpl_transferTo0(JNIEnv *env, jobject this, |
|
27937
0c9f63e42e91
8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents:
25859
diff
changeset
|
145 |
jobject srcFDO, |
2 | 146 |
jlong position, jlong count, |
27937
0c9f63e42e91
8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents:
25859
diff
changeset
|
147 |
jobject dstFDO) |
2 | 148 |
{ |
27937
0c9f63e42e91
8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents:
25859
diff
changeset
|
149 |
jint srcFD = fdval(env, srcFDO); |
0c9f63e42e91
8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents:
25859
diff
changeset
|
150 |
jint dstFD = fdval(env, dstFDO); |
0c9f63e42e91
8064407: (fc) FileChannel transferTo should use TransmitFile on Windows
alanb
parents:
25859
diff
changeset
|
151 |
|
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
152 |
#if defined(__linux__) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
153 |
off64_t offset = (off64_t)position; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
154 |
jlong n = sendfile64(dstFD, srcFD, &offset, (size_t)count); |
2 | 155 |
if (n < 0) { |
156 |
if (errno == EAGAIN) |
|
157 |
return IOS_UNAVAILABLE; |
|
158 |
if ((errno == EINVAL) && ((ssize_t)count >= 0)) |
|
159 |
return IOS_UNSUPPORTED_CASE; |
|
160 |
if (errno == EINTR) { |
|
161 |
return IOS_INTERRUPTED; |
|
162 |
} |
|
163 |
JNU_ThrowIOExceptionWithLastError(env, "Transfer failed"); |
|
164 |
return IOS_THROWN; |
|
165 |
} |
|
166 |
return n; |
|
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
167 |
#elif defined (__solaris__) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
168 |
sendfilevec64_t sfv; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
169 |
size_t numBytes = 0; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
170 |
jlong result; |
2 | 171 |
|
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
172 |
sfv.sfv_fd = srcFD; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
173 |
sfv.sfv_flag = 0; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
174 |
sfv.sfv_off = (off64_t)position; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
175 |
sfv.sfv_len = count; |
2 | 176 |
|
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
177 |
result = sendfilev64(dstFD, &sfv, 1, &numBytes); |
2 | 178 |
|
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
179 |
/* Solaris sendfilev() will return -1 even if some bytes have been |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
180 |
* transferred, so we check numBytes first. |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
181 |
*/ |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
182 |
if (numBytes > 0) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
183 |
return numBytes; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
184 |
if (result < 0) { |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
185 |
if (errno == EAGAIN) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
186 |
return IOS_UNAVAILABLE; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
187 |
if (errno == EOPNOTSUPP) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
188 |
return IOS_UNSUPPORTED_CASE; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
189 |
if ((errno == EINVAL) && ((ssize_t)count >= 0)) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
190 |
return IOS_UNSUPPORTED_CASE; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
191 |
if (errno == EINTR) |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
192 |
return IOS_INTERRUPTED; |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
193 |
JNU_ThrowIOExceptionWithLastError(env, "Transfer failed"); |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
194 |
return IOS_THROWN; |
2 | 195 |
} |
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
196 |
return result; |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
197 |
#elif defined(__APPLE__) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
198 |
off_t numBytes; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
199 |
int result; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
200 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
201 |
numBytes = count; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
202 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
203 |
result = sendfile(srcFD, dstFD, position, &numBytes, NULL, 0); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
204 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
205 |
if (numBytes > 0) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
206 |
return numBytes; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
207 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
208 |
if (result == -1) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
209 |
if (errno == EAGAIN) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
210 |
return IOS_UNAVAILABLE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
211 |
if (errno == EOPNOTSUPP || errno == ENOTSOCK || errno == ENOTCONN) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
212 |
return IOS_UNSUPPORTED_CASE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
213 |
if ((errno == EINVAL) && ((ssize_t)count >= 0)) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
214 |
return IOS_UNSUPPORTED_CASE; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
215 |
if (errno == EINTR) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
216 |
return IOS_INTERRUPTED; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
217 |
JNU_ThrowIOExceptionWithLastError(env, "Transfer failed"); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
218 |
return IOS_THROWN; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
219 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
220 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
221 |
return result; |
24575
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
222 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
223 |
#elif defined(_AIX) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
224 |
jlong max = (jlong)java_lang_Integer_MAX_VALUE; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
225 |
struct sf_parms sf_iobuf; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
226 |
jlong result; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
227 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
228 |
if (position > max) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
229 |
return IOS_UNSUPPORTED_CASE; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
230 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
231 |
if (count > max) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
232 |
count = max; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
233 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
234 |
memset(&sf_iobuf, 0, sizeof(sf_iobuf)); |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
235 |
sf_iobuf.file_descriptor = srcFD; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
236 |
sf_iobuf.file_offset = (off_t)position; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
237 |
sf_iobuf.file_bytes = count; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
238 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
239 |
result = send_file(&dstFD, &sf_iobuf, SF_SYNC_CACHE); |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
240 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
241 |
/* AIX send_file() will return 0 when this operation complete successfully, |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
242 |
* return 1 when partial bytes transfered and return -1 when an error has |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
243 |
* Occured. |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
244 |
*/ |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
245 |
if (result == -1) { |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
246 |
if (errno == EWOULDBLOCK) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
247 |
return IOS_UNAVAILABLE; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
248 |
if ((errno == EINVAL) && ((ssize_t)count >= 0)) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
249 |
return IOS_UNSUPPORTED_CASE; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
250 |
if (errno == EINTR) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
251 |
return IOS_INTERRUPTED; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
252 |
if (errno == ENOTSOCK) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
253 |
return IOS_UNSUPPORTED; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
254 |
JNU_ThrowIOExceptionWithLastError(env, "Transfer failed"); |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
255 |
return IOS_THROWN; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
256 |
} |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
257 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
258 |
if (sf_iobuf.bytes_sent > 0) |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
259 |
return (jlong)sf_iobuf.bytes_sent; |
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
260 |
|
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
261 |
return IOS_UNSUPPORTED_CASE; |
7971
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
262 |
#else |
ca5a32210b1b
7002957: (fc) FileChannel.transferTo fails to load libsendfile on Solaris 64-bit
alanb
parents:
5506
diff
changeset
|
263 |
return IOS_UNSUPPORTED_CASE; |
2 | 264 |
#endif |
265 |
} |
|
24575
c1b197bb86c2
8043495: Add native FileChannelImpl.transferTo0() implementation for AIX
luchsh
parents:
14342
diff
changeset
|
266 |