# HG changeset patch # User alanb # Date 1339776985 -3600 # Node ID ada1a7c54e845ceaff93e139a4ab628e9da8494c # Parent 2bb2271eadf60d93ca76128d45f24cc12bd3f0d7 7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX Reviewed-by: chegar, coffeys diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/make/java/nio/mapfile-linux --- a/jdk/make/java/nio/mapfile-linux Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/make/java/nio/mapfile-linux Fri Jun 15 17:16:25 2012 +0100 @@ -88,6 +88,7 @@ Java_sun_nio_ch_IOUtil_fdVal; Java_sun_nio_ch_IOUtil_fdLimit; Java_sun_nio_ch_IOUtil_initIDs; + Java_sun_nio_ch_IOUtil_iovMax; Java_sun_nio_ch_IOUtil_makePipe; Java_sun_nio_ch_IOUtil_randomBytes; Java_sun_nio_ch_IOUtil_setfdVal; diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/make/java/nio/mapfile-solaris --- a/jdk/make/java/nio/mapfile-solaris Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/make/java/nio/mapfile-solaris Fri Jun 15 17:16:25 2012 +0100 @@ -76,6 +76,7 @@ Java_sun_nio_ch_IOUtil_fdLimit; Java_sun_nio_ch_IOUtil_fdVal; Java_sun_nio_ch_IOUtil_initIDs; + Java_sun_nio_ch_IOUtil_iovMax; Java_sun_nio_ch_IOUtil_makePipe; Java_sun_nio_ch_IOUtil_randomBytes; Java_sun_nio_ch_IOUtil_setfdVal; diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/src/share/classes/sun/nio/ch/IOUtil.java --- a/jdk/src/share/classes/sun/nio/ch/IOUtil.java Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/src/share/classes/sun/nio/ch/IOUtil.java Fri Jun 15 17:16:25 2012 +0100 @@ -36,6 +36,11 @@ public class IOUtil { + /** + * Max number of iovec structures that readv/writev supports + */ + static final int IOV_MAX; + private IOUtil() { } // No instantiation static int write(FileDescriptor fd, ByteBuffer src, long position, @@ -111,7 +116,8 @@ // Iterate over buffers to populate native iovec array. int count = offset + length; - for (int i=offset; i bufferCache = diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c --- a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c Fri Jun 15 17:16:25 2012 +0100 @@ -94,9 +94,6 @@ { jint fd = fdval(env, fdo); struct iovec *iov = (struct iovec *)jlong_to_ptr(address); - if (len > 16) { - len = 16; - } return convertLongReturnVal(env, readv(fd, iov, len), JNI_TRUE); } @@ -126,9 +123,6 @@ { jint fd = fdval(env, fdo); struct iovec *iov = (struct iovec *)jlong_to_ptr(address); - if (len > 16) { - len = 16; - } return convertLongReturnVal(env, writev(fd, iov, len), JNI_FALSE); } diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/src/solaris/native/sun/nio/ch/IOUtil.c --- a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c Fri Jun 15 17:16:25 2012 +0100 @@ -136,6 +136,16 @@ } } +JNIEXPORT jint JNICALL +Java_sun_nio_ch_IOUtil_iovMax(JNIEnv *env, jclass this) +{ + jlong iov_max = sysconf(_SC_IOV_MAX); + if (iov_max == -1) + iov_max = 16; + return (jint)iov_max; +} + + /* Declared in nio_util.h for use elsewhere in NIO */ jint diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/src/windows/native/sun/nio/ch/IOUtil.c --- a/jdk/src/windows/native/sun/nio/ch/IOUtil.c Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/src/windows/native/sun/nio/ch/IOUtil.c Fri Jun 15 17:16:25 2012 +0100 @@ -41,9 +41,6 @@ /* field id for jint 'fd' in java.io.FileDescriptor used for socket fds */ static jfieldID fd_fdID; -/* false for 95/98/ME, true for NT/W2K */ -static jboolean onNT = JNI_FALSE; - JNIEXPORT jboolean JNICALL Java_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed (JNIEnv *env, jclass clazz, jbyteArray randArray); @@ -55,13 +52,6 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) { - OSVERSIONINFO ver; - ver.dwOSVersionInfoSize = sizeof(ver); - GetVersionEx(&ver); - if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) { - onNT = JNI_TRUE; - } - clazz = (*env)->FindClass(env, "java/io/FileDescriptor"); fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I"); handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J"); @@ -80,6 +70,13 @@ randArray); } +JNIEXPORT jint JNICALL +Java_sun_nio_ch_IOUtil_iovMax(JNIEnv *env, jclass this) +{ + return 16; +} + + jint convertReturnVal(JNIEnv *env, jint n, jboolean reading) { @@ -205,9 +202,3 @@ { return (*env)->GetLongField(env, fdo, handle_fdID); } - -jboolean -isNT() -{ - return onNT; -} diff -r 2bb2271eadf6 -r ada1a7c54e84 jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c --- a/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c Fri Jun 15 09:16:18 2012 -0400 +++ b/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c Fri Jun 15 17:16:25 2012 +0100 @@ -97,10 +97,6 @@ return IOS_THROWN; } - if ((isNT() == JNI_FALSE) && (len > 16)) { - len = 16; - } - /* copy iovec into WSABUF */ for(i=0; i 16)) { - len = 16; - } - /* copy iovec into WSABUF */ for(i=0; i