From 8cae9bc720f85834a757e01ec9862bf8a69da47e Mon Sep 17 00:00:00 2001 From: alanb Date: Fri, 15 Jun 2012 17:16:25 +0100 Subject: [PATCH] 7176485: (bf) Allow temporary buffer cache to grow to IOV_MAX Reviewed-by: chegar, coffeys --- make/java/nio/mapfile-linux | 1 + make/java/nio/mapfile-solaris | 1 + src/share/classes/sun/nio/ch/IOUtil.java | 16 +++++++++++-- src/share/classes/sun/nio/ch/Util.java | 2 +- .../native/sun/nio/ch/FileDispatcherImpl.c | 6 ----- src/solaris/native/sun/nio/ch/IOUtil.c | 10 ++++++++ src/windows/native/sun/nio/ch/IOUtil.c | 23 ++++++------------- .../native/sun/nio/ch/SocketDispatcher.c | 8 ------- src/windows/native/sun/nio/ch/nio_util.h | 1 - 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/make/java/nio/mapfile-linux b/make/java/nio/mapfile-linux index 61153101d..63c9cbf14 100644 --- a/make/java/nio/mapfile-linux +++ b/make/java/nio/mapfile-linux @@ -88,6 +88,7 @@ SUNWprivate_1.1 { 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 --git a/make/java/nio/mapfile-solaris b/make/java/nio/mapfile-solaris index 7767d13a7..5a4908e1f 100644 --- a/make/java/nio/mapfile-solaris +++ b/make/java/nio/mapfile-solaris @@ -76,6 +76,7 @@ SUNWprivate_1.1 { 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 --git a/src/share/classes/sun/nio/ch/IOUtil.java b/src/share/classes/sun/nio/ch/IOUtil.java index 6b4dc6f3a..a8267534c 100644 --- a/src/share/classes/sun/nio/ch/IOUtil.java +++ b/src/share/classes/sun/nio/ch/IOUtil.java @@ -36,6 +36,11 @@ import java.nio.ByteBuffer; 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 @@ public class IOUtil { // Iterate over buffers to populate native iovec array. int count = offset + length; - for (int i=offset; i bufferCache = diff --git a/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c b/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c index 6808dbea9..4d987b91f 100644 --- a/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c +++ b/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c @@ -94,9 +94,6 @@ Java_sun_nio_ch_FileDispatcherImpl_readv0(JNIEnv *env, jclass clazz, { 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 @@ Java_sun_nio_ch_FileDispatcherImpl_writev0(JNIEnv *env, jclass clazz, { 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 --git a/src/solaris/native/sun/nio/ch/IOUtil.c b/src/solaris/native/sun/nio/ch/IOUtil.c index 4bea68826..77ea58060 100644 --- a/src/solaris/native/sun/nio/ch/IOUtil.c +++ b/src/solaris/native/sun/nio/ch/IOUtil.c @@ -136,6 +136,16 @@ Java_sun_nio_ch_IOUtil_fdLimit(JNIEnv *env, jclass this) } } +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 --git a/src/windows/native/sun/nio/ch/IOUtil.c b/src/windows/native/sun/nio/ch/IOUtil.c index 7549b994f..8b03be4b3 100644 --- a/src/windows/native/sun/nio/ch/IOUtil.c +++ b/src/windows/native/sun/nio/ch/IOUtil.c @@ -41,9 +41,6 @@ static jfieldID handle_fdID; /* 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 @@ Java_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed 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 @@ Java_sun_nio_ch_IOUtil_randomBytes(JNIEnv *env, jclass clazz, 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 @@ handleval(JNIEnv *env, jobject fdo) { return (*env)->GetLongField(env, fdo, handle_fdID); } - -jboolean -isNT() -{ - return onNT; -} diff --git a/src/windows/native/sun/nio/ch/SocketDispatcher.c b/src/windows/native/sun/nio/ch/SocketDispatcher.c index 373d92da7..e765149eb 100644 --- a/src/windows/native/sun/nio/ch/SocketDispatcher.c +++ b/src/windows/native/sun/nio/ch/SocketDispatcher.c @@ -97,10 +97,6 @@ Java_sun_nio_ch_SocketDispatcher_readv0(JNIEnv *env, jclass clazz, jobject fdo, 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