RFC on 8165823: (se) EPollArrayWrapper throws NPE if limits.conf set to 65536 and fd=65536

Brian Burkhalter brian.burkhalter at oracle.com
Tue Oct 11 18:22:35 UTC 2016


Hello Thomas, Christoph,

On Oct 10, 2016, at 12:34 AM, Thomas Stüfe <thomas.stuefe at gmail.com> wrote:

> The only input I could give is that on some platforms getrlimit() may return RLIM_INFINITY for NOFILE, which has to be handled. But I do not think this is the case on Linux.

The RLIM_INFINITY case is handled in the native layer [1] therefore this should not be a problem in this situation:
JNIEXPORT jint JNICALL
Java_sun_nio_ch_IOUtil_fdLimit(JNIEnv *env, jclass this)
{
    struct rlimit rlp;
    if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) {
        JNU_ThrowIOExceptionWithLastError(env, "getrlimit failed");
        return -1;
    }
    if (rlp.rlim_max == RLIM_INFINITY ||
        rlp.rlim_max > (rlim_t)java_lang_Integer_MAX_VALUE) {
        return java_lang_Integer_MAX_VALUE;
    } else {
        return (jint)rlp.rlim_max;
    }
}
Thanks,

Brian

[1] http://hg.openjdk.java.net/jdk9/dev/jdk/file/b909daf8fdbc/src/java.base/unix/native/libnio/ch/IOUtil.c, lines 124-138
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20161011/2e24a4d6/attachment.html>


More information about the nio-dev mailing list