eventmachine/eventmachine — pull request #502 by piki (2014-03-12 05:33:40+00:00)
Title: Use the rb_fd_* API to get autosized fd_sets

Fixes #501

On Ruby 1.9.1 and up, we use `rb_fd_select` and friends to get automatically resized `fd_set`s. This should transparently provide correct behavior for `select` even when fds exceed `FD_SETSIZE` (1024).

On Ruby 1.8.7 and 1.9.0, we use stubs that warn to stdout whenever anyone tries to `FD_SET`, `FD_CLR`, `FD_ISSET`, or `select` an fd >= `FD_SETSIZE`. This behavior isn't correct, in that it's noisy and doesn't do anything useful with the high FDs. But it's better than the current behavior, which is undefined and usually crashes with an unrelated assert or heap corruption after the first high FD.

There's another branch [here](https://github.com/piki/eventmachine/blob/backport-rb-fd/ext/rbselect.impl) that backports the rb_fd_* API. I've only tested that branch on Debian squeeze (6.0), which has Ruby 1.8.7. It's unlikely to work on WIN32 without further effort. I can merge it into this PR if someone wants to tidy it up for Ruby <= 1.9.0 on WIN32.