RFR [9] 8035897 : FD_SETSIZE should be set on macosx
Chris Hegarty
chris.hegarty at oracle.com
Fri Feb 28 06:40:23 PST 2014
[ Volker: there are some trivial AIX changes here, maybe you could
verify them? ]
JDK-8021820 adds -D_DARWIN_UNLIMITED_SELECT to the build, but the fd_set
struct is still limited to 1024.
Snippet from man select(2):
"Although the provision of getdtablesize(2) was intended to allow
user programs to be written
independent of the kernel limit on the number of open files, the
dimension of a sufficiently
large bit field for select remains a problem. The default size
FD_SETSIZE (currently 1024) is
somewhat smaller than the current kernel limit to the number of
open files. However, in order
to accommodate programs which might potentially use a larger
number of open files with select,
it is possible to increase this size within a program by providing
a larger definition of
FD_SETSIZE before the inclusion of <sys/types.h>.
Either:
1) FD_SETSIZE needs to be set to a larger value, but what value, the
kernel limit, or other? This is wasteful for most typical apps that
don't use large numbers of file descriptors. Or,
2) If fd is greater than 1024, then an appropriate amount of memory
could be allocated and cast to an fd_set. The FD_SET macro will
write past FD_SETSIZE.
I think option 2 is preferable:
http://cr.openjdk.java.net/~chegar/8035897/webrev.00/webrev/
I'm still checking to see it an automatic regression test is possible,
but I wanted to circulate the changes for comment first.
Thanks,
-Chris.
More information about the net-dev
mailing list