United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6824477 (se) Selector.select fails with IOException: "Invalid argument" if maximum file descriptors is low
JDK-6824477 : (se) Selector.select fails with IOException: "Invalid argument" if maximum file descriptors is low

Details
Type:
Bug
Submit Date:
2009-03-31
Status:
Resolved
Updated Date:
2010-07-09
Project Name:
JDK
Resolved Date:
2009-04-11
Component:
core-libs
OS:
generic
Sub-Component:
java.nio
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
A customer using Glassfish encounters the following exception:

SEVERE: Exception during controller processing
java.io.IOException: Invalid argument
   at sun.nio.ch.DevPollArrayWrapper.registerMultiple(Native Method)
   at sun.nio.ch.DevPollArrayWrapper.updateRegistrations(DevPollArrayWrapper.java:220)
   at sun.nio.ch.DevPollArrayWrapper.poll(DevPollArrayWrapper.java:163)
   at sun.nio.ch.DevPollSelectorImpl.doSelect(DevPollSelectorImpl.java:68)
   at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
   at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
   at com.sun.grizzly.TCPSelectorHandler.select(TCPSelectorHandler.java:476)
   at com.sun.grizzly.Controller.doSelect(Controller.java:350)
   at com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:81)
   at com.sun.grizzly.Controller.startSelectorHandlerRunner(Controller.java:1144)
   at 

SunOS vorlon 5.11 snv_101b i86pc i386 i86pc Solaris

                                    

Comments
SUGGESTED FIX

diff -r ff0a9e50f033 src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java
--- a/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java   Mon Mar 30 19:22:27 2009 +0100
+++ b/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java   Tue Mar 31 21:09:42 2009 +0100
@@ -77,7 +77,7 @@ class DevPollArrayWrapper {
     private long pollArrayAddress;

     // Maximum number of POLL_FD structs to update at once
-    private int MAX_UPDATE_SIZE = 10000;
+    private int MAX_UPDATE_SIZE = Math.min(OPEN_MAX, 10000);

     DevPollArrayWrapper() {
         int allocationSize = NUM_POLLFDS * SIZE_POLLFD;
                                     
2009-03-31
WORK AROUND

Increase the maximum number of file descriptors to 10000 or greater (the default on Solaris is 64k).
                                     
2009-03-31
EVALUATION

The /dev/poll driver limits the number of pollfd structs that can be written to the driver in a single batch to the maximum number of file descriptors. The Selector implementation, on the other hand, limits the number of updates in a single batch to 10000. By default the maximum number of file descriptors is 64k so this is not a problem. In this customer's case, the limit is 2048 so >2048 updates will cause the exception in the description.
                                     
2009-03-31



Hardware and Software, Engineered to Work Together