author | alanb |
Wed, 28 Feb 2018 09:54:38 +0000 | |
changeset 49001 | ce06058197a4 |
parent 48750 | ffbb784a8873 |
child 49290 | 07779973cbe2 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
48750
ffbb784a8873
8196787: (ch) Moving network channels to use j.u.c locks
alanb
parents:
47726
diff
changeset
|
2 |
* Copyright (c) 2000, 2018, 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 |
package sun.nio.ch; |
|
27 |
||
28 |
import java.io.FileDescriptor; |
|
29 |
import java.io.IOException; |
|
30 |
import java.nio.ByteBuffer; |
|
31 |
||
32 |
||
33 |
/** |
|
34 |
* File-descriptor based I/O utilities that are shared by NIO classes. |
|
35 |
*/ |
|
36 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
9237
diff
changeset
|
37 |
public class IOUtil { |
2 | 38 |
|
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
39 |
/** |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
40 |
* Max number of iovec structures that readv/writev supports |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
41 |
*/ |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
42 |
static final int IOV_MAX; |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
43 |
|
2 | 44 |
private IOUtil() { } // No instantiation |
45 |
||
46 |
static int write(FileDescriptor fd, ByteBuffer src, long position, |
|
16921
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
14342
diff
changeset
|
47 |
NativeDispatcher nd) |
2 | 48 |
throws IOException |
49 |
{ |
|
47428 | 50 |
return write(fd, src, position, false, -1, nd); |
51 |
} |
|
52 |
||
53 |
static int write(FileDescriptor fd, ByteBuffer src, long position, |
|
54 |
boolean directIO, int alignment, NativeDispatcher nd) |
|
55 |
throws IOException |
|
56 |
{ |
|
57 |
if (src instanceof DirectBuffer) { |
|
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48750
diff
changeset
|
58 |
return writeFromNativeBuffer(fd, src, position, directIO, alignment, nd); |
47428 | 59 |
} |
2 | 60 |
|
61 |
// Substitute a native buffer |
|
62 |
int pos = src.position(); |
|
63 |
int lim = src.limit(); |
|
64 |
assert (pos <= lim); |
|
65 |
int rem = (pos <= lim ? lim - pos : 0); |
|
47428 | 66 |
ByteBuffer bb; |
67 |
if (directIO) { |
|
68 |
Util.checkRemainingBufferSizeAligned(rem, alignment); |
|
69 |
bb = Util.getTemporaryAlignedDirectBuffer(rem, alignment); |
|
70 |
} else { |
|
71 |
bb = Util.getTemporaryDirectBuffer(rem); |
|
72 |
} |
|
2 | 73 |
try { |
74 |
bb.put(src); |
|
75 |
bb.flip(); |
|
76 |
// Do not update src until we see how many bytes were written |
|
77 |
src.position(pos); |
|
78 |
||
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48750
diff
changeset
|
79 |
int n = writeFromNativeBuffer(fd, bb, position, directIO, alignment, nd); |
2 | 80 |
if (n > 0) { |
81 |
// now update src |
|
82 |
src.position(pos + n); |
|
83 |
} |
|
84 |
return n; |
|
85 |
} finally { |
|
6301 | 86 |
Util.offerFirstTemporaryDirectBuffer(bb); |
2 | 87 |
} |
88 |
} |
|
89 |
||
90 |
private static int writeFromNativeBuffer(FileDescriptor fd, ByteBuffer bb, |
|
47428 | 91 |
long position, boolean directIO, |
92 |
int alignment, NativeDispatcher nd) |
|
2 | 93 |
throws IOException |
94 |
{ |
|
95 |
int pos = bb.position(); |
|
96 |
int lim = bb.limit(); |
|
97 |
assert (pos <= lim); |
|
98 |
int rem = (pos <= lim ? lim - pos : 0); |
|
99 |
||
47428 | 100 |
if (directIO) { |
101 |
Util.checkBufferPositionAligned(bb, pos, alignment); |
|
102 |
Util.checkRemainingBufferSizeAligned(rem, alignment); |
|
103 |
} |
|
104 |
||
2 | 105 |
int written = 0; |
106 |
if (rem == 0) |
|
107 |
return 0; |
|
108 |
if (position != -1) { |
|
109 |
written = nd.pwrite(fd, |
|
110 |
((DirectBuffer)bb).address() + pos, |
|
16921
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
14342
diff
changeset
|
111 |
rem, position); |
2 | 112 |
} else { |
113 |
written = nd.write(fd, ((DirectBuffer)bb).address() + pos, rem); |
|
114 |
} |
|
115 |
if (written > 0) |
|
116 |
bb.position(pos + written); |
|
117 |
return written; |
|
118 |
} |
|
119 |
||
120 |
static long write(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) |
|
121 |
throws IOException |
|
122 |
{ |
|
47428 | 123 |
return write(fd, bufs, 0, bufs.length, false, -1, nd); |
6301 | 124 |
} |
2 | 125 |
|
6301 | 126 |
static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
127 |
NativeDispatcher nd) |
|
128 |
throws IOException |
|
129 |
{ |
|
47428 | 130 |
return write(fd, bufs, offset, length, false, -1, nd); |
131 |
} |
|
132 |
||
133 |
static long write(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
|
134 |
boolean directIO, int alignment, NativeDispatcher nd) |
|
135 |
throws IOException |
|
136 |
{ |
|
6301 | 137 |
IOVecWrapper vec = IOVecWrapper.get(length); |
2 | 138 |
|
6301 | 139 |
boolean completed = false; |
140 |
int iov_len = 0; |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
141 |
try { |
6301 | 142 |
|
143 |
// Iterate over buffers to populate native iovec array. |
|
144 |
int count = offset + length; |
|
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
145 |
int i = offset; |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
146 |
while (i < count && iov_len < IOV_MAX) { |
6301 | 147 |
ByteBuffer buf = bufs[i]; |
148 |
int pos = buf.position(); |
|
149 |
int lim = buf.limit(); |
|
150 |
assert (pos <= lim); |
|
151 |
int rem = (pos <= lim ? lim - pos : 0); |
|
47428 | 152 |
if (directIO) |
153 |
Util.checkRemainingBufferSizeAligned(rem, alignment); |
|
154 |
||
6301 | 155 |
if (rem > 0) { |
156 |
vec.setBuffer(iov_len, buf, pos, rem); |
|
157 |
||
158 |
// allocate shadow buffer to ensure I/O is done with direct buffer |
|
159 |
if (!(buf instanceof DirectBuffer)) { |
|
47428 | 160 |
ByteBuffer shadow; |
161 |
if (directIO) |
|
48750
ffbb784a8873
8196787: (ch) Moving network channels to use j.u.c locks
alanb
parents:
47726
diff
changeset
|
162 |
shadow = Util.getTemporaryAlignedDirectBuffer(rem, alignment); |
47428 | 163 |
else |
164 |
shadow = Util.getTemporaryDirectBuffer(rem); |
|
6301 | 165 |
shadow.put(buf); |
166 |
shadow.flip(); |
|
167 |
vec.setShadow(iov_len, shadow); |
|
168 |
buf.position(pos); // temporarily restore position in user buffer |
|
169 |
buf = shadow; |
|
170 |
pos = shadow.position(); |
|
171 |
} |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
172 |
|
6301 | 173 |
vec.putBase(iov_len, ((DirectBuffer)buf).address() + pos); |
174 |
vec.putLen(iov_len, rem); |
|
175 |
iov_len++; |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
176 |
} |
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
177 |
i++; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
178 |
} |
6301 | 179 |
if (iov_len == 0) |
180 |
return 0L; |
|
181 |
||
182 |
long bytesWritten = nd.writev(fd, vec.address, iov_len); |
|
183 |
||
184 |
// Notify the buffers how many bytes were taken |
|
185 |
long left = bytesWritten; |
|
186 |
for (int j=0; j<iov_len; j++) { |
|
187 |
if (left > 0) { |
|
188 |
ByteBuffer buf = vec.getBuffer(j); |
|
189 |
int pos = vec.getPosition(j); |
|
190 |
int rem = vec.getRemaining(j); |
|
191 |
int n = (left > rem) ? rem : (int)left; |
|
192 |
buf.position(pos + n); |
|
193 |
left -= n; |
|
194 |
} |
|
195 |
// return shadow buffers to buffer pool |
|
196 |
ByteBuffer shadow = vec.getShadow(j); |
|
197 |
if (shadow != null) |
|
198 |
Util.offerLastTemporaryDirectBuffer(shadow); |
|
199 |
vec.clearRefs(j); |
|
200 |
} |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
201 |
|
6301 | 202 |
completed = true; |
203 |
return bytesWritten; |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
204 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
205 |
} finally { |
6301 | 206 |
// if an error occurred then clear refs to buffers and return any shadow |
207 |
// buffers to cache |
|
208 |
if (!completed) { |
|
209 |
for (int j=0; j<iov_len; j++) { |
|
210 |
ByteBuffer shadow = vec.getShadow(j); |
|
211 |
if (shadow != null) |
|
212 |
Util.offerLastTemporaryDirectBuffer(shadow); |
|
213 |
vec.clearRefs(j); |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
214 |
} |
2 | 215 |
} |
216 |
} |
|
217 |
} |
|
218 |
||
219 |
static int read(FileDescriptor fd, ByteBuffer dst, long position, |
|
16921
e70261f11307
8012019: (fc) Thread.interrupt triggers hang in FileChannelImpl.pread (win)
alanb
parents:
14342
diff
changeset
|
220 |
NativeDispatcher nd) |
2 | 221 |
throws IOException |
222 |
{ |
|
47428 | 223 |
return read(fd, dst, position, false, -1, nd); |
224 |
} |
|
225 |
||
226 |
static int read(FileDescriptor fd, ByteBuffer dst, long position, |
|
227 |
boolean directIO, int alignment, NativeDispatcher nd) |
|
228 |
throws IOException |
|
229 |
{ |
|
2 | 230 |
if (dst.isReadOnly()) |
231 |
throw new IllegalArgumentException("Read-only buffer"); |
|
232 |
if (dst instanceof DirectBuffer) |
|
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48750
diff
changeset
|
233 |
return readIntoNativeBuffer(fd, dst, position, directIO, alignment, nd); |
2 | 234 |
|
235 |
// Substitute a native buffer |
|
47428 | 236 |
ByteBuffer bb; |
237 |
int rem = dst.remaining(); |
|
238 |
if (directIO) { |
|
239 |
Util.checkRemainingBufferSizeAligned(rem, alignment); |
|
48750
ffbb784a8873
8196787: (ch) Moving network channels to use j.u.c locks
alanb
parents:
47726
diff
changeset
|
240 |
bb = Util.getTemporaryAlignedDirectBuffer(rem, alignment); |
47428 | 241 |
} else { |
242 |
bb = Util.getTemporaryDirectBuffer(rem); |
|
243 |
} |
|
2 | 244 |
try { |
49001
ce06058197a4
8198562: (ch) Separate blocking and non-blocking code paths (part 1)
alanb
parents:
48750
diff
changeset
|
245 |
int n = readIntoNativeBuffer(fd, bb, position, directIO, alignment,nd); |
2 | 246 |
bb.flip(); |
247 |
if (n > 0) |
|
248 |
dst.put(bb); |
|
249 |
return n; |
|
250 |
} finally { |
|
6301 | 251 |
Util.offerFirstTemporaryDirectBuffer(bb); |
2 | 252 |
} |
253 |
} |
|
254 |
||
255 |
private static int readIntoNativeBuffer(FileDescriptor fd, ByteBuffer bb, |
|
47428 | 256 |
long position, boolean directIO, |
257 |
int alignment, NativeDispatcher nd) |
|
2 | 258 |
throws IOException |
259 |
{ |
|
260 |
int pos = bb.position(); |
|
261 |
int lim = bb.limit(); |
|
262 |
assert (pos <= lim); |
|
263 |
int rem = (pos <= lim ? lim - pos : 0); |
|
264 |
||
47428 | 265 |
if (directIO) { |
266 |
Util.checkBufferPositionAligned(bb, pos, alignment); |
|
267 |
Util.checkRemainingBufferSizeAligned(rem, alignment); |
|
268 |
} |
|
269 |
||
2 | 270 |
if (rem == 0) |
271 |
return 0; |
|
272 |
int n = 0; |
|
273 |
if (position != -1) { |
|
48750
ffbb784a8873
8196787: (ch) Moving network channels to use j.u.c locks
alanb
parents:
47726
diff
changeset
|
274 |
n = nd.pread(fd, ((DirectBuffer)bb).address() + pos, rem, position); |
2 | 275 |
} else { |
276 |
n = nd.read(fd, ((DirectBuffer)bb).address() + pos, rem); |
|
277 |
} |
|
278 |
if (n > 0) |
|
279 |
bb.position(pos + n); |
|
280 |
return n; |
|
281 |
} |
|
282 |
||
283 |
static long read(FileDescriptor fd, ByteBuffer[] bufs, NativeDispatcher nd) |
|
284 |
throws IOException |
|
285 |
{ |
|
47428 | 286 |
return read(fd, bufs, 0, bufs.length, false, -1, nd); |
6301 | 287 |
} |
288 |
||
289 |
static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
|
290 |
NativeDispatcher nd) |
|
291 |
throws IOException |
|
292 |
{ |
|
47726
a85bb15efb57
8191025: (ch) Scattering reads to a subsequence of buffers ignores length
bpb
parents:
47428
diff
changeset
|
293 |
return read(fd, bufs, offset, length, false, -1, nd); |
47428 | 294 |
} |
295 |
||
296 |
static long read(FileDescriptor fd, ByteBuffer[] bufs, int offset, int length, |
|
297 |
boolean directIO, int alignment, NativeDispatcher nd) |
|
298 |
throws IOException |
|
299 |
{ |
|
6301 | 300 |
IOVecWrapper vec = IOVecWrapper.get(length); |
301 |
||
302 |
boolean completed = false; |
|
303 |
int iov_len = 0; |
|
304 |
try { |
|
2 | 305 |
|
6301 | 306 |
// Iterate over buffers to populate native iovec array. |
307 |
int count = offset + length; |
|
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
308 |
int i = offset; |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
309 |
while (i < count && iov_len < IOV_MAX) { |
6301 | 310 |
ByteBuffer buf = bufs[i]; |
311 |
if (buf.isReadOnly()) |
|
312 |
throw new IllegalArgumentException("Read-only buffer"); |
|
313 |
int pos = buf.position(); |
|
314 |
int lim = buf.limit(); |
|
315 |
assert (pos <= lim); |
|
316 |
int rem = (pos <= lim ? lim - pos : 0); |
|
317 |
||
47428 | 318 |
if (directIO) |
319 |
Util.checkRemainingBufferSizeAligned(rem, alignment); |
|
320 |
||
6301 | 321 |
if (rem > 0) { |
322 |
vec.setBuffer(iov_len, buf, pos, rem); |
|
2 | 323 |
|
6301 | 324 |
// allocate shadow buffer to ensure I/O is done with direct buffer |
325 |
if (!(buf instanceof DirectBuffer)) { |
|
47428 | 326 |
ByteBuffer shadow; |
327 |
if (directIO) { |
|
48750
ffbb784a8873
8196787: (ch) Moving network channels to use j.u.c locks
alanb
parents:
47726
diff
changeset
|
328 |
shadow = Util.getTemporaryAlignedDirectBuffer(rem, alignment); |
47428 | 329 |
} else { |
330 |
shadow = Util.getTemporaryDirectBuffer(rem); |
|
331 |
} |
|
6301 | 332 |
vec.setShadow(iov_len, shadow); |
333 |
buf = shadow; |
|
334 |
pos = shadow.position(); |
|
335 |
} |
|
336 |
||
337 |
vec.putBase(iov_len, ((DirectBuffer)buf).address() + pos); |
|
338 |
vec.putLen(iov_len, rem); |
|
339 |
iov_len++; |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
340 |
} |
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
341 |
i++; |
2 | 342 |
} |
6301 | 343 |
if (iov_len == 0) |
344 |
return 0L; |
|
345 |
||
346 |
long bytesRead = nd.readv(fd, vec.address, iov_len); |
|
347 |
||
348 |
// Notify the buffers how many bytes were read |
|
349 |
long left = bytesRead; |
|
350 |
for (int j=0; j<iov_len; j++) { |
|
351 |
ByteBuffer shadow = vec.getShadow(j); |
|
352 |
if (left > 0) { |
|
353 |
ByteBuffer buf = vec.getBuffer(j); |
|
354 |
int rem = vec.getRemaining(j); |
|
355 |
int n = (left > rem) ? rem : (int)left; |
|
356 |
if (shadow == null) { |
|
357 |
int pos = vec.getPosition(j); |
|
358 |
buf.position(pos + n); |
|
359 |
} else { |
|
360 |
shadow.limit(shadow.position() + n); |
|
361 |
buf.put(shadow); |
|
362 |
} |
|
363 |
left -= n; |
|
364 |
} |
|
365 |
if (shadow != null) |
|
366 |
Util.offerLastTemporaryDirectBuffer(shadow); |
|
367 |
vec.clearRefs(j); |
|
368 |
} |
|
2 | 369 |
|
6301 | 370 |
completed = true; |
371 |
return bytesRead; |
|
2 | 372 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
373 |
} finally { |
6301 | 374 |
// if an error occurred then clear refs to buffers and return any shadow |
375 |
// buffers to cache |
|
376 |
if (!completed) { |
|
377 |
for (int j=0; j<iov_len; j++) { |
|
378 |
ByteBuffer shadow = vec.getShadow(j); |
|
379 |
if (shadow != null) |
|
380 |
Util.offerLastTemporaryDirectBuffer(shadow); |
|
381 |
vec.clearRefs(j); |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
2
diff
changeset
|
382 |
} |
2 | 383 |
} |
384 |
} |
|
385 |
} |
|
386 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
9237
diff
changeset
|
387 |
public static FileDescriptor newFD(int i) { |
2 | 388 |
FileDescriptor fd = new FileDescriptor(); |
389 |
setfdVal(fd, i); |
|
390 |
return fd; |
|
391 |
} |
|
392 |
||
393 |
static native boolean randomBytes(byte[] someBytes); |
|
394 |
||
6520
0e7cf575332e
6981145: (se) Eliminate JNI*Critical when creating pipes and other cleanups
martin
parents:
6301
diff
changeset
|
395 |
/** |
0e7cf575332e
6981145: (se) Eliminate JNI*Critical when creating pipes and other cleanups
martin
parents:
6301
diff
changeset
|
396 |
* Returns two file descriptors for a pipe encoded in a long. |
0e7cf575332e
6981145: (se) Eliminate JNI*Critical when creating pipes and other cleanups
martin
parents:
6301
diff
changeset
|
397 |
* The read end of the pipe is returned in the high 32 bits, |
0e7cf575332e
6981145: (se) Eliminate JNI*Critical when creating pipes and other cleanups
martin
parents:
6301
diff
changeset
|
398 |
* while the write end is returned in the low 32 bits. |
0e7cf575332e
6981145: (se) Eliminate JNI*Critical when creating pipes and other cleanups
martin
parents:
6301
diff
changeset
|
399 |
*/ |
0e7cf575332e
6981145: (se) Eliminate JNI*Critical when creating pipes and other cleanups
martin
parents:
6301
diff
changeset
|
400 |
static native long makePipe(boolean blocking); |
2 | 401 |
|
402 |
static native boolean drain(int fd) throws IOException; |
|
403 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
9237
diff
changeset
|
404 |
public static native void configureBlocking(FileDescriptor fd, |
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
9237
diff
changeset
|
405 |
boolean blocking) |
2 | 406 |
throws IOException; |
407 |
||
11823
ee83ae88512d
7041778: Move SCTP implementation out of sun.nio.ch and into its own package
chegar
parents:
9237
diff
changeset
|
408 |
public static native int fdVal(FileDescriptor fd); |
2 | 409 |
|
410 |
static native void setfdVal(FileDescriptor fd, int value); |
|
411 |
||
12872
16fa902b1469
7172826: (se) Selector based on the Solaris event port mechanism
alanb
parents:
11823
diff
changeset
|
412 |
static native int fdLimit(); |
16fa902b1469
7172826: (se) Selector based on the Solaris event port mechanism
alanb
parents:
11823
diff
changeset
|
413 |
|
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
414 |
static native int iovMax(); |
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
415 |
|
2 | 416 |
static native void initIDs(); |
417 |
||
19607
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
418 |
/** |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
419 |
* Used to trigger loading of native libraries |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
420 |
*/ |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
421 |
public static void load() { } |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
422 |
|
2 | 423 |
static { |
19607
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
424 |
java.security.AccessController.doPrivileged( |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
425 |
new java.security.PrivilegedAction<Void>() { |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
426 |
public Void run() { |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
427 |
System.loadLibrary("net"); |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
428 |
System.loadLibrary("nio"); |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
429 |
return null; |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
430 |
} |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
431 |
}); |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
432 |
|
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
433 |
initIDs(); |
bee007586d06
8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents:
16921
diff
changeset
|
434 |
|
13024
ada1a7c54e84
7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX
alanb
parents:
12872
diff
changeset
|
435 |
IOV_MAX = iovMax(); |
2 | 436 |
} |
437 |
||
438 |
} |