Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8035897

Better memory allocation for file descriptors greater than 1024 on macosx

    Details

    • Subcomponent:
    • Resolved In Build:
      b04
    • CPU:
      generic
    • OS:
      os_x
    • Verification:
      Verified

      Backports

        Description

        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.

        Option 2 above seems most reasonable. Will proceed with making the appropriate changes.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  chegar Chris Hegarty
                  Reporter:
                  chegar Chris Hegarty
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  10 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: