JDK-6824477 : (se) Selector.select fails with IOException: "Invalid argument" if maximum file descriptors is low
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-03-31
  • Updated: 2010-07-09
  • Resolved: 2009-04-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u18Fixed 7 b55Fixed
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;
31-03-2009

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.
31-03-2009

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