Giter VIP home page Giter VIP logo

nio4r's Introduction

nio4r

Development Status

New I/O for Ruby (nio4r): cross-platform asynchronous I/O primitives for scalable network clients and servers. Modeled after the Java NIO API, but simplified for ease-of-use.

nio4r provides an abstract, cross-platform stateful I/O selector API for Ruby. I/O selectors are the heart of "reactor"-based event loops, and monitor multiple I/O objects for various types of readiness, e.g. ready for reading or writing.

Projects using nio4r

  • ActionCable: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
  • Celluloid: Actor-based concurrency framework, uses nio4r for async I/O
  • Async: Asynchronous I/O framework for Ruby
  • Puma: Ruby/Rack web server built for concurrency

Goals

  • Expose high-level interfaces for stateful IO selectors
  • Keep the API small to maximize both portability and performance across many different OSes and Ruby VMs
  • Provide inherently thread-safe facilities for working with IO objects

Supported platforms

Supported backends

  • libev: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
  • Java NIO: JRuby extension which wraps the Java NIO subsystem
  • Pure Ruby: Kernel.select-based backend that should work on any Ruby interpreter

Documentation

Please see the nio4r wiki for more detailed documentation and usage notes:

  • Getting Started: Introduction to nio4r's components
  • Selectors: monitor multiple IO objects for readiness events
  • Monitors: control interests and inspect readiness for specific IO objects
  • Byte Buffers: fixed-size native buffers for high-performance I/O

See also:

Non-goals

nio4r is not a full-featured event framework like EventMachine or Cool.io. Instead, nio4r is the sort of thing you might write a library like that on top of. nio4r provides a minimal API such that individual Ruby implementers may choose to produce optimized versions for their platform, without having to maintain a large codebase.

Releases

Bump the version first:

bundle exec bake gem:release:version:patch

CRuby

rake clean
rake release

JRuby

You might need to delete Gemfile.lock before trying to bundle install.

# Ensure you have the correct JDK:
pacman -Syu jdk-openjdk
archlinux-java set java-19-openjdk

# Ensure you are using jruby:
chruby jruby
bundle update

# Build the package:
rake clean
rake compile
rake release

nio4r's People

Contributors

ahorek avatar avsej avatar boazsegev avatar boutil avatar dbussink avatar djberg96 avatar eregon avatar frsyuki avatar halorgium avatar honeyryderchuck avatar hsbt avatar ioquatix avatar jcmfernandes avatar jesus avatar junaruga avatar loganb avatar luislavena avatar marshall-lee avatar msp-greg avatar olleolleolle avatar stakach avatar tarcieri avatar thedrow avatar thomasdziedzic avatar tompng avatar tsimnujhawj avatar unak avatar upekshejay avatar voxik avatar vsppedro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nio4r's Issues

Recursive locking (pure ruby)

I'm getting a recursive lock error when running the example echo server

Client

telnet localhost 1234
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

Server

NIO4r_PURE=true ruby examples/echo_server.rb
Listening on localhost:1234
*** ::1:61932 connected
<internal:prelude>:8:in `lock': deadlock; recursive locking (ThreadError)
    from <internal:prelude>:8:in `synchronize'
    from /Users/johnnyt/code/celluloid/nio4r/lib/nio/selector.rb:22:in `register'
    from examples/echo_server.rb:29:in `accept'
    from examples/echo_server.rb:15:in `block in initialize'
    from examples/echo_server.rb:20:in `call'
    from examples/echo_server.rb:20:in `block in run'
    from /Users/johnnyt/code/celluloid/nio4r/lib/nio/selector.rb:94:in `block (2 levels) in select'
    from /Users/johnnyt/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/set.rb:222:in `block in each'
    from /Users/johnnyt/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/set.rb:222:in `each_key'
    from /Users/johnnyt/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/set.rb:222:in `each'
    from /Users/johnnyt/code/celluloid/nio4r/lib/nio/selector.rb:93:in `block in select'
    from <internal:prelude>:10:in `synchronize'
    from /Users/johnnyt/code/celluloid/nio4r/lib/nio/selector.rb:54:in `select'
    from examples/echo_server.rb:20:in `run'
    from examples/echo_server.rb:46:in `<main>'

jruby 1.7

are you planning on supporting ffi since c extensions are deprecated in 1.7?

`require': cannot load such file -- nio4r_ext (LoadError) - extension will not be copied into lib directory

On some boxes nio4r_ext.so will not be copied into the lib directory, so nio isn't usable until I copy the extension manually.

$ cat /etc/debian_version
6.0.7
$ ruby -v
ruby 2.0.0p247 (2013-06-27) [x86_64-linux]
$ uname -a
Linux debian-squeeze 3.10.5 #3 SMP Thu Aug 8 13:42:21 CEST 2013 x86_64 GNU/Linux
$ echo -e "source \"https://rubygems.org\"\ngem 'nio4r'" > Gemfile
$ bundle install --path vendor/bundle
Resolving dependencies...
Installing nio4r (0.5.0)
Using bundler (1.3.5)
Your bundle is complete!
It was installed into ./vendor/bundle
$ bundle exec ruby -rnio -e "puts 'test'"
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require': cannot load such file -- nio4r_ext (LoadError)
        from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
        from /var/tmp/niotest/vendor/bundle/ruby/2.0.0/gems/nio4r-0.5.0/lib/nio.rb:19:in `<top (required)>'
        from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in `require'
        from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:60:in `rescue in require'
        from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:35:in `require'
$ ls vendor/bundle/ruby/2.0.0/gems/nio4r-0.5.0/lib/
nio  nio.rb  usr
$ cp vendor/bundle/ruby/2.0.0/gems/nio4r-0.5.0/ext/nio4r/nio4r_ext.so vendor/bundle/ruby/2.0.0/gems/nio4r-0.5.0/lib/
$ bundle exec ruby -rnio -e "puts 'test'"test
test
```sh

Windows error

On both the C implementation and the pure ruby implementation, windows seems to throw Errno::EBADF when calling read_nonblock(1024) it also throws Errno::EPIPE: Broken pipe when calling wakeup

locking in reactor severely limits usage for network clients

If you have clients that are making a lot of network calls, the locking around registering io objects will cap you to a very low concurrency. We do exactly that on a large jruby + rails application, and I've been looking for an alternative to eventmachine when I found this. Unfortunately, those locks would kill us.

Two solutions I can think of.

  • Add an option to disable the locking. This would work for a lot of us. Especially for jruby apps, you often just run a reactor in it's own thread anyways. In some cases you might run a small pool of reactors to take advantage of multiple cores. We use zeromq to communicate between our app threads and the reactor thread.
  • For jruby, use ConcurrentHashMap instead of a mutex. Not free, but much less expensive then synchronize and you will get much higher concurrencies.

The problem with ConcurrentHashMap approach is that anything that's using a reactor pattern for clients, is probably running at a high enough concurrency where even ConcurrentHashMap will have issues.

Chris

Build failed while installing nio4r on OSX Mavericks

GCC:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

Ruby:

ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

OS:

ProductName:    Mac OS X
ProductVersion: 10.9.2
BuildVersion:   13C64

Results of running gem install nio4r:

Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
1 warning generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:481:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1535:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2806:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2809:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2819:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2820:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2821:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2832:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2850:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2863:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2867:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2868:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3050:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3112:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3257:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
./../libev/ev.c:3274:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3446:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3620:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3621:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3630:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3632:34: warning: '&' within '|' [-Wbitwise-op-parentheses]
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                       ~~~~~~~~~~^~~~~~~~~~~~~ ~
./../libev/ev.c:3632:34: note: place parentheses around the '&' expression to silence this warning
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                                 ^
                       (                      )
./../libev/ev.c:3645:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3665:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3693:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3755:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3787:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3824:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3827:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3945:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4524:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
32 warnings generated.
compiling selector.c
In file included from selector.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from selector.c:7:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubysig.h:14:2: warning: rubysig.h is obsolete [-W#warnings]
#warning rubysig.h is obsolete
 ^
selector.c:391:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:391:76: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                                                           ^~~~
                                                                           &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
selector.c:407:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:407:77: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                                                            ^~~~
                                                                            &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
6 warnings generated.
linking shared-object nio4r_ext.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [nio4r_ext.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nio4r-1.0.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nio4r-1.0.0/gem_make.out

IOError: closed stream when running load test

I'm able to reproduce this issue with the simplified code that can be found here:
https://gist.github.com/romansergey/5103388
with jruby-1.7.2

I'm launching reel via server.rb and start hitting it with:
ab -k -c 100 -n 1000 http://127.0.0.1:3000/

and it crashes on about 18-19th request:

Starting server...
E, [2013-03-06T22:42:59.152000 #8039] ERROR -- : MyServer crashed!
IOError: closed stream
    org/nio4r/Nio4r.java:143:in `register'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-io-0.13.0.pre/lib/celluloid/io/reactor.rb:42:in `wait'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-io-0.13.0.pre/lib/celluloid/io/reactor.rb:21:in `wait_readable'
    org/jruby/RubyBasicObject.java:1665:in `__send__'
    org/jruby/RubyKernel.java:1809:in `public_send'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-0.13.0.pre/lib/celluloid/calls.rb:11:in `dispatch'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-0.13.0.pre/lib/celluloid/calls.rb:60:in `dispatch'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-0.13.0.pre/lib/celluloid/actor.rb:328:in `handle_message'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-0.13.0.pre/lib/celluloid/tasks/task_fiber.rb:28:in `initialize'
    /home/me/.rvm/gems/jruby-1.7.2/gems/celluloid-0.13.0.pre/lib/celluloid/tasks/task_fiber.rb:27:in `initialize'
D, [2013-03-06T22:42:59.225000 #8039] DEBUG -- : Terminating 146 actors...
D, [2013-03-06T22:42:59.457000 #8039] DEBUG -- : Shutdown completed cleanly

Thank you!

Trouble installing from Vagrant plugin on Mountain Lion/Xcode 5

Hi,

TL;DR The nio4r gem builds fine on my Ruby 1.9.3 but fails to build from Vagrant's Ruby interpreter.

There seems to be an issue with Xcode >=4.6.3 on Mountain Lion being unable to compile some gems with native code using the Vagrant >= 1.3.4 embedded Ruby, in this case nio4r.

I've also submitted this as an issue to the Vagrant team.

hashicorp/vagrant#2402

One other vagrant-berkshelf user, @zepheiryan dug into the issue a little deeper, from the thread on the vagrant-berkshelf issue.

I'm having the same problem with about the same environment, except I have a full XCode install.

Looking at the files the error messages point to, I see the conflict is that OS X defines structs timeval and timespec, but the parameters to tell Ruby that those aren't missing aren't provided in nio4r's extconf.rb (it should define HAVE_STRUCT_TIMESPEC and HAVE_STRUCT_TIMEVAL based on the presence of sys/_structs.h, perhaps in a platform-dependent manner; it does not).

I "solved" this by temporarily commenting out the struct definitions of Vagrant's embedded Ruby's missing.h. I also had to make sure my ARCHFLAGS was unset for my environment because the embedded Ruby does not provide headers for x86_64-darwin12.3.0, only universal. The install succeeded after making those changes.

I have no qualms about doing this locally just to get this working since Ruby development is low on my activities list, but I'm guessing as a real solution, this is an issue to bring up with the nio4r team. I'll file an issue there if that makes sense to others.

Full output of the error trace below:

unknown28cfe9162235 :: ~/src/vgrnt โ€นmaster*โ€บ % vagrant plugin install vagrant-berkshelf 1 โ†ต
Installing the 'vagrant-berkshelf' plugin. This can take a few minutes...
/Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:562:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

    /Applications/Vagrant/embedded/bin/ruby extconf.rb

checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Applications/Vagrant/embedded/bin/ruby
/Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:455:inblock in try_link0'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/tmpdir.rb:83:in mktmpdir' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:452:intry_link0'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:476:in try_link' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:619:intry_func'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:894:in block in have_func' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:790:inblock in checking_for'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:284:in block (2 levels) in postpone' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:254:inopen'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:254:inopen'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/mkmf.rb:893:in have_func' from extconf.rb:3:in

'

Gem files will remain installed in /Users/Michael/.vagrant.d/gems/gems/nio4r-0.5.0 for inspection.
Results logged to /Users/Michael/.vagrant.d/gems/gems/nio4r-0.5.0/ext/nio4r/gem_make.out
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:540:in block in build_extensions' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:515:ineach'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:515:in build_extensions' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/installer.rb:180:ininstall'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:297:in block in install' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:ineach'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:in each_with_index' from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/dependency_installer.rb:270:ininstall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/action/install_gem.rb:49:in block in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/gem_helper.rb:42:inblock in with_environment'
from /Applications/Vagrant/embedded/lib/ruby/1.9.1/rubygems/user_interaction.rb:40:in use_ui' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/gem_helper.rb:41:inwith_environment'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/action/install_gem.rb:39:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/action/bundler_check.rb:20:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:incall'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builder.rb:116:in call' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:inblock in run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/util/busy.rb:19:in busy' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:inrun'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/command/base.rb:17:in action' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/command/install.rb:27:inexecute'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/commands/plugin/command/root.rb:52:in execute' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/cli.rb:38:inexecute'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/environment.rb:478:in cli' from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/bin/vagrant:96:in<top (required)>'
from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in load' from /Applications/Vagrant/bin/../embedded/gems/bin/vagrant:23:in

'

Provide separate return values for #select on timeout vs. wakeup

Here's my IO loop:

while @selector.registered?(@io)
  num_updated = @selector.select(timeout) { โ€ฆ }

  write(:ping) if num_updated.nil? # previous attempt at handling this, but pings when @selector.wakeup too.

  # My suggestion of how it could look after this issue is resolved.
  case num_updated
  when :timeout
    write(:ping)
  when :wakeup
    # no op
  when nil
    # spurious wakeup
  else
    # num_updated is an integer of number of monitors updated.
  end
end

Sometimes my monitor is not registered with writing in mind. When I want to write data I append it to an output buffer, and then wake the selector up so that it will notice the output buffer and send it on the IO channel.

def write(message)
  @output_buffer << message
  @selector.wakeup
end

In my first piece of code I'd like to only yield if a timeout occurred, so that I can ping the connection if no data is sent or received for X seconds. However, when I write data and wake the selector up (which happen more often than timeouts) I don't want to send a ping/pong request.

My thinking is that if a timeout occurs the #select call can return e.g. :timeout, and if woken up it can return :wakeup, and in case of spurious wakeup I suppose it would be nil.

Version 1.0.1 fails to build on OS X 10.9.4

I'm trying install Berkshelf, which depends on Celluloid. This morning I found that my bundle install on a new project fails. It looks like there was a change between version 1.0.1 and 1.0.0 of nio4r which caused the C extension to fail building. If I fix my Gemfile to resolve nio4r to version 1.0.0, everything installs correctly.

The gem_make.out for the failed build is below:

/opt/chefdk/embedded/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/opt/chefdk/embedded/bin/ruby
/opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:556:in `try_link'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:742:in `try_func'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:1027:in `block in have_func'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /opt/chefdk/embedded/lib/ruby/2.1.0/mkmf.rb:1026:in `have_func'
    from extconf.rb:3:in `<main>'

extconf failed, exit code 1

Thank you in advance!

Segfault in RBX

This has been tested with nio4r 1.1.0 under both RBX 2.5.2 and master (i.e. rubinius/rubinius@8ffed61). In both cases I am running the following:

sysname: Linux
release: 3.18.6-1-ARCH
version: #1 SMP PREEMPT Sat Feb 7 08:44:05 CET 2015
machine: x86_64

No clue as to what the issue is, but it seems to be something to to with registering and deregistering an IO object at the same time that the object is being closed ... something like that!

Here is a test script. Apologies if it is a tad noisy:

require 'rubygems'
require 'nio'
require 'socket'

s = NIO::Selector.new

# Actually I don't think this part is necessary for the bug
Thread.new do
  loop do
    puts "select"
    if ready = s.select(0.1)
      puts "yay"
    end
  end
end

1000.times do
  a,b = UNIXSocket.pair
  Thread.new do
    10.times do
      s.register(a, :r)
      s.deregister(a)
    end
  end

  Thread.new do
    a.close
  end
end

sleep 1 while true

When I run this I get some messages followed by The Rubinius process is aborting with signal: SIGSEGV. First few lines of the backtrace are:

ruby() [0x6b5cf9]
/usr/lib/libpthread.so.0(+0x10740) [0x7ff632abf740]
/usr/lib/libc.so.6(fileno_unlocked+0) [0x7ff6318cdc40]
/home/asp/.rvm/gems/rbx-2.5.2/gems/nio4r-1.1.0/lib/nio4r_ext.so(+0xa32c) [0x7ff63144b32c]
ruby(_ZN8rubinius12NativeMethod23executor_implementationINS_14ThreeArgumentsEEEPNS_6ObjectEPNS_5StateEPNS_9CallFrameEPNS_10ExecutableEPNS_6ModuleERNS_9ArgumentsE+0x419) [0x71e6f9]
ruby(_ZN8rubinius11MachineCode11interpreterEPNS_5StateEPS0_PNS_20InterpreterCallFrameE+0x2aed) [0x5fc7cd]
ruby(_ZN8rubinius11MachineCode19execute_specializedINS_17SplatOnlyArgumentEEEPNS_6ObjectEPNS_5StateEPNS_9CallFrameEPNS_10ExecutableEPNS_6ModuleERNS_9ArgumentsE+0x277) [0x64a737]
ruby(_ZN8rubinius8Dispatch4sendEPNS_5StateEPNS_9CallFrameERNS_10LookupDataERNS_9ArgumentsENS_19MethodMissingReasonE+0x6c) [0x5dbb5c]

I'm happy to provide more info if needed. Cheers!

Failing to build on Arch Linux (Ruby 2.2.1p85)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20150311-18836-jlnd0q.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... yes
checking for sys/event.h... no
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling selector.c
In file included from nio4r.h:10:0,
                 from selector.c:6:
/usr/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
 #warning use "ruby/io.h" instead of "rubyio.h"
  ^
In file included from selector.c:7:0:
/usr/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
 #warning rubysig.h is obsolete
  ^
selector.c: In function โ€˜NIO_Selector_runโ€™:
selector.c:341:9: error: โ€˜TRAP_BEGโ€™ undeclared (first use in this function)
         TRAP_BEG;
         ^
selector.c:341:9: note: each undeclared identifier is reported only once for each function it appears in
selector.c:343:9: error: โ€˜TRAP_ENDโ€™ undeclared (first use in this function)
         TRAP_END;
         ^
selector.c: In function โ€˜NIO_Selector_closeโ€™:
selector.c:391:43: warning: passing argument 2 of โ€˜NIO_Selector_synchronizeโ€™ from incompatible pointer type
     return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                           ^
selector.c:157:14: note: expected โ€˜VALUE (*)(VALUE *)โ€™ but argument is of type โ€˜VALUE (*)(VALUE)โ€™
 static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
              ^
selector.c:391:76: warning: passing argument 3 of โ€˜NIO_Selector_synchronizeโ€™ makes pointer from integer without a cast
     return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                                                            ^
selector.c:157:14: note: expected โ€˜VALUE *โ€™ but argument is of type โ€˜VALUEโ€™
 static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
              ^
selector.c: In function โ€˜NIO_Selector_closedโ€™:
selector.c:407:43: warning: passing argument 2 of โ€˜NIO_Selector_synchronizeโ€™ from incompatible pointer type
     return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                           ^
selector.c:157:14: note: expected โ€˜VALUE (*)(VALUE *)โ€™ but argument is of type โ€˜VALUE (*)(VALUE)โ€™
 static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
              ^
selector.c:407:77: warning: passing argument 3 of โ€˜NIO_Selector_synchronizeโ€™ makes pointer from integer without a cast
     return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                                                             ^
selector.c:157:14: note: expected โ€˜VALUE *โ€™ but argument is of type โ€˜VALUEโ€™
 static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
              ^
selector.c: In function โ€˜NIO_Selector_wakeupโ€™:
selector.c:384:5: warning: ignoring return value of โ€˜writeโ€™, declared with attribute warn_unused_result [-Wunused-result]
     write(selector->wakeup_writer, "\0", 1);
     ^
Makefile:237: recipe for target 'selector.o' failed
make: *** [selector.o] Error 1

make failed, exit code 2

Build fails on Windows 7 x64 with ruby 2.0.0p195 (2013-05-14) [i386-mingw32]

C:\rbxops\Vagrant> gem install nio4r
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.

C:/Ruby/Ruby200/bin/ruby.exe extconf.rb

checking for rb_thread_blocking_region()... yes
checking for sys/select.h... no
checking for poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... no
checking for port.h... no
checking for sys/resource.h... no
creating Makefile

make
generating nio4r_ext-i386-mingw32.def
compiling monitor.c
In file included from nio4r.h:10:0,
from monitor.c:6:
c:/Ruby/Ruby200/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
In file included from nio4r.h:11:0,
from monitor.c:6:
libev.h:5:0: warning: "FD_SETSIZE" redefined [enabled by default]
:0:0: note: this is the location of the previous definition
monitor.c: In function 'NIO_Monitor_initialize':
monitor.c:103:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
monitor.c:103:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
monitor.c:103:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
monitor.c: At top level:
monitor.c:30:13: warning: 'NIO_Monitor_callback' declared 'static' but never defined [-Wunused-function]
compiling nio4r_ext.c
In file included from nio4r.h:10:0,
from nio4r_ext.c:6:
c:/Ruby/Ruby200/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
In file included from nio4r.h:11:0,
from nio4r_ext.c:6:
libev.h:5:0: warning: "FD_SETSIZE" redefined [enabled by default]
:0:0: note: this is the location of the previous definition
In file included from nio4r_ext.c:7:0:
../libev/ev.c:474:48: warning: "/" within comment [-Wcomment]
In file included from ../libev/ev.c:1005:0,
from nio4r_ext.c:7:
../libev/ev_win32.c: In function 'ev_pipe':
../libev/ev_win32.c:84:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
In file included from nio4r_ext.c:7:0:
../libev/ev.c: At top level:
../libev/ev.c:1258:31: warning: 'ev_default_loop_ptr' initialized and declared 'extern' [enabled by default]
../libev/ev.c: In function 'array_nextsize':
../libev/ev.c:1367:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
../libev/ev.c: In function 'fd_reify':
../libev/ev.c:1515:15: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'evpipe_init':
../libev/ev.c:1815:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'ev_feed_signal':
../libev/ev.c:1951:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
In file included from ../libev/ev.c:2091:0,
from nio4r_ext.c:7:
../libev/ev_select.c: In function 'select_modify':
../libev/ev_select.c:85:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev_select.c: At top level:
../libev/ev_select.c:274:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
../libev/ev_select.c:274:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
../libev/ev_select.c:303:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
../libev/ev_select.c:303:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
In file included from nio4r_ext.c:7:0:
../libev/ev.c:2107:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
../libev/ev.c:2107:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
../libev/ev.c: In function 'loop_init':
../libev/ev.c:2309:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:2309:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:2309:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:2312:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:2312:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:2312:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:2313:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'ev_loop_destroy':
../libev/ev.c:2347:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'loop_fork':
../libev/ev.c:2457:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'verify_watcher':
../libev/ev.c:2508:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:2511:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'verify_heap':
../libev/ev.c:2521:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:2522:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:2523:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'array_verify':
../libev/ev.c:2534:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_verify':
../libev/ev.c:2552:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:2559:9: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:2560:9: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'timers_reify':
../libev/ev.c:2737:15: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'periodics_reify':
../libev/ev.c:2801:15: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:2788:11: warning: unused variable 'feed_count' [-Wunused-variable]
../libev/ev.c: In function 'ev_backend_poll':
../libev/ev.c:2946:1: warning: no return statement in function returning non-void [-Wreturn-type]
../libev/ev.c: In function 'ev_run':
../libev/ev.c:2963:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:3120:9: warning: 'rb_thread_blocking_region' is deprecated (declared at c:/Ruby/Ruby200/include/ruby-2.0.0/ruby/intern.h:835) [-Wdeprecated-declarations]
../libev/ev.c:3134:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:3134:13: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_io_start':
../libev/ev.c:3306:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:3307:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_io_stop':
../libev/ev.c:3328:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_timer_start':
../libev/ev.c:3348:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_timer_stop':
../libev/ev.c:3376:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_periodic_start':
../libev/ev.c:3438:7: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_periodic_stop':
../libev/ev.c:3470:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c: In function 'ev_signal_start':
../libev/ev.c:3507:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:3510:3: warning: left-hand operand of comma expression has no effect [-Wunused-value]
In file included from nio4r_ext.c:7:0:
../libev/ev.c: In function 'ev_stat_start':
../libev/ev.c:3962:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:3962:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:3962:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:3962:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:3963:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'ev_stat_stop':
../libev/ev.c:3995:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'ev_embed_start':
../libev/ev.c:4197:5: warning: left-hand operand of comma expression has no effect [-Wunused-value]
../libev/ev.c:4198:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4198:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4198:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4203:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4206:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4206:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4206:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4207:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4210:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4210:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4210:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: In function 'ev_once':
../libev/ev.c:4420:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4420:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4420:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4427:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4427:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4427:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c:4430:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
../libev/ev.c: At top level:
../libev/ev.c:4546:27: warning: "/
" within comment [-Wcomment]
../libev/ev.c:4547:27: warning: "/" within comment [-Wcomment]
In file included from nio4r_ext.c:7:0:
../libev/ev.c:1622:1: warning: 'fd_rearm_all' defined but not used [-Wunused-function]
compiling selector.c
In file included from nio4r.h:10:0,
from selector.c:6:
c:/Ruby/Ruby200/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h" [-Wcpp]
In file included from nio4r.h:11:0,
from selector.c:6:
libev.h:5:0: warning: "FD_SETSIZE" redefined [enabled by default]
:0:0: note: this is the location of the previous definition
In file included from selector.c:7:0:
c:/Ruby/Ruby200/include/ruby-2.0.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
selector.c: In function 'NIO_Selector_allocate':
selector.c:84:5: warning: implicit declaration of function 'pipe' [-Wimplicit-function-declaration]
selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
selector.c:94:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
selector.c:99:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
selector.c: In function 'NIO_Selector_synchronize':
selector.c:159:11: warning: variable 'current_thread' set but not used [-Wunused-but-set-variable]
selector.c: In function 'NIO_Selector_deregister_synchronized':
selector.c:235:11: warning: unused variable 'monitor_args' [-Wunused-variable]
selector.c:234:21: warning: unused variable 'interests' [-Wunused-variable]
selector.c: In function 'NIO_Selector_select':
selector.c:262:20: warning: unused variable 'array' [-Wunused-variable]
selector.c: In function 'NIO_Selector_select_synchronized':
selector.c:280:9: warning: unused variable 'i' [-Wunused-variable]
selector.c: In function 'NIO_Selector_close':
selector.c:385:5: warning: passing argument 2 of 'NIO_Selector_synchronize' from incompatible pointer type [enabled by default]
selector.c:157:14: note: expected 'VALUE (
)(VALUE )' but argument is of type 'VALUE ()(VALUE)'
selector.c:385:5: warning: passing argument 3 of 'NIO_Selector_synchronize' makes pointer from integer without a cast [enabled by default]
selector.c:157:14: note: expected 'VALUE ' but argument is of type 'VALUE'
selector.c: In function 'NIO_Selector_closed':
selector.c:401:5: warning: passing argument 2 of 'NIO_Selector_synchronize' from incompatible pointer type [enabled by default]
selector.c:157:14: note: expected 'VALUE (
)(VALUE )' but argument is of type 'VALUE ()(VALUE)'
selector.c:401:5: warning: passing argument 3 of 'NIO_Selector_synchronize' makes pointer from integer without a cast [enabled by default]
selector.c:157:14: note: expected 'VALUE ' but argument is of type 'VALUE'
linking shared-object nio4r_ext.so
c:/ruby/ruby200sdk/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: warning: cannot find entry symbol xport-all; defaulting to 0000000061741000
nio4r_ext.o: In function get_clock': C:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\nio4r-0.4.6\ext\nio4r/../libev/ev.c:1311: undefined reference toclock_gettime'
C:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\nio4r-0.4.6\ext\nio4r/../libev/ev.c:1311: undefined reference to clock_gettime' C:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\nio4r-0.4.6\ext\nio4r/../libev/ev.c:1311: undefined reference toclock_gettime'
C:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\nio4r-0.4.6\ext\nio4r/../libev/ev.c:1311: undefined reference to clock_gettime' C:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\nio4r-0.4.6\ext\nio4r/../libev/ev.c:1311: undefined reference toclock_gettime'
nio4r_ext.o:C:\Ruby\Ruby200\lib\ruby\gems\2.0.0\gems\nio4r-0.4.6\ext\nio4r/../libev/ev.c:1311: more undefined references to `clock_gettime' follow
collect2.exe: error: ld returned 1 exit status
make: *
* [nio4r_ext.so] Error 1

Gem files will remain installed in C:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/nio4r-0.4.6 for inspection.
Results logged to C:/Ruby/Ruby200/lib/ruby/gems/2.0.0/gems/nio4r-0.4.6/ext/nio4r/gem_make.out
C:\rbxops\Vagrant> ruby -v
ruby 2.0.0p195 (2013-05-14) [i386-mingw32]
C:\rbxops\Vagrant>

Segfault in Celluloid::IO specs due to thread safety issue in nio4r

The Celluloid::IO specs sometimes crash on Rubinius, which is due to a thread safety issue in nio4r. The problem is that a NIO_Selector is being shut down while it's waiting in epoll_wait concurrently. This causes undefined behaviour because data structures are still used after cleanup. This often manifests as corruption in Rubinius which subsequently crashes in different ways.

Rubinius doesn't enable the C-API lock anymore by default, but even with the C-API lock this is still a problem since the epoll_wait() happens in a rb_thread_block_region.

Here is a gdb log of the problem, showing the different threads in the state that is problematic here:

(gdb) info threads
  Id   Target Id         Frame 
  13   Thread 0x7fffee2f9700 (LWP 18226) "rbx" 0x00007ffff6aa9a43 in epoll_wait () from /usr/lib/libc.so.6
  8    Thread 0x7fffee90a700 (LWP 18221) "rbx" 0x00007ffff7284954 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  7    Thread 0x7fffeed0b700 (LWP 18220) "rbx" 0x00007ffff7284954 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  6    Thread 0x7fffef5ce700 (LWP 18219) "rbx" 0x00007ffff7284954 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
  5    Thread 0x7ffff57f4700 (LWP 18218) "rbx" 0x00007ffff6aa3073 in select () from /usr/lib/libc.so.6
* 1    Thread 0x7ffff7fed740 (LWP 18209) "rbx" NIO_Selector_shutdown (selector=0x2a24bb0) at selector.c:124
(gdb)

As you can see here, thread 13 is in epoll_wait() but thread 1 is cleaning up the selector. This is the (partial) C++ and the Ruby backtrace for thread 1:

(gdb) bt 
#0  NIO_Selector_shutdown (selector=0x2a2acd0) at selector.c:124
#1  0x00007fffee2ff1bf in NIO_Selector_close (self=33386032) at selector.c:405
#2  0x000000000083f7ed in rubinius::ZeroArguments::invoke (state=0x17ef8a0, nm=0x7ffff694a048, env=0x1846160, args=...) at vm/builtin/nativemethod.cpp:226
#3  0x000000000084276b in rubinius::NativeMethod::executor_implementation (state=0x17ef8a0, call_frame=0x7ffffffde550, exec=0x7ffff694a048, mod=0x283afe0, args=...) at vm/builtin/nativemethod.cpp:706
#4  0x00000000006a0bc7 in rubinius::Dispatch::send (this=0x7ffffffdd440, state=0x17ef8a0, call_frame=0x7ffffffde550, lookup=..., args=..., reason=rubinius::eNormal) at vm/dispatch.cpp:42
#5  0x0000000000846e33 in rubinius::Object::send_prim (this=0x7ffff66390f8, state=0x17ef8a0, call_frame=0x7ffffffde550, exec=0x7ffff5ebbca0, mod=0x18333b0, args=..., min_visibility=0xac6) at vm/builtin/object.cpp:562
#6  0x0000000000846ea1 in rubinius::Object::private_send_prim (this=0x7ffff66390f8, state=0x17ef8a0, call_frame=0x7ffffffde550, exec=0x7ffff5ebbca0, mod=0x18333b0, args=...) at vm/builtin/object.cpp:566
#7  0x0000000000764cb4 in rubinius::Primitives::object_send (state=0x17ef8a0, call_frame=0x7ffffffde550, exec=0x7ffff5ebbca0, mod=0x18333b0, args=...) at vm/gen/method_primitives.cpp:10876
#8  0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x17ef8a0, cache=0x2a1aee8, call_frame=0x7ffffffde550, args=...) at vm/inline_cache.cpp:592
#9  0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x2a1aee8, state=0x17ef8a0, call_frame=0x7ffffffde550, args=...) at vm/inline_cache.hpp:197
#10 0x00000000006c1f1d in rubinius::MachineCode::interpreter (state=0x17ef8a0, mcode=0x2a1a740, call_frame=0x7ffffffde550) at ./vm/gen/instruction_implementations.hpp:571
#11 0x00000000007375f7 in rubinius::MachineCode::execute_specialized (state=0x17ef8a0, previous=0x7ffffffdf730, exec=0x7ffff68dafb8, mod=0x282ea50, args=...) at vm/machine_code.cpp:630
#12 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x17ef8a0, cache=0x2a073a0, call_frame=0x7ffffffdf730, args=...) at vm/inline_cache.cpp:592
#13 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x2a073a0, state=0x17ef8a0, call_frame=0x7ffffffdf730, args=...) at vm/inline_cache.hpp:197
#14 0x00000000006c1b35 in rubinius::MachineCode::interpreter (state=0x17ef8a0, mcode=0x2a071d0, call_frame=0x7ffffffdf730) at ./vm/gen/instruction_implementations.hpp:524
#15 0x0000000000737170 in rubinius::MachineCode::execute_specialized (state=0x17ef8a0, previous=0x7ffffffe08c0, exec=0x7ffff68b4688, mod=0x28151d0, args=...) at vm/machine_code.cpp:630
#16 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x17ef8a0, cache=0x2a19d38, call_frame=0x7ffffffe08c0, args=...) at vm/inline_cache.cpp:592
#17 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x2a19d38, state=0x17ef8a0, call_frame=0x7ffffffe08c0, args=...) at vm/inline_cache.hpp:197
#18 0x00000000006c1b35 in rubinius::MachineCode::interpreter (state=0x17ef8a0, mcode=0x2a19760, call_frame=0x7ffffffe08c0) at ./vm/gen/instruction_implementations.hpp:524
#19 0x0000000000737a7e in rubinius::MachineCode::execute_specialized (state=0x17ef8a0, previous=0x7ffffffe1aa0, exec=0x7ffff4e31fc0, mod=0x284fd70, args=...) at vm/machine_code.cpp:630
#20 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x17ef8a0, cache=0x29d7968, call_frame=0x7ffffffe1aa0, args=...) at vm/inline_cache.cpp:592
#21 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x29d7968, state=0x17ef8a0, call_frame=0x7ffffffe1aa0, args=...) at vm/inline_cache.hpp:197
#22 0x00000000006c1b35 in rubinius::MachineCode::interpreter (state=0x17ef8a0, mcode=0x29d7110, call_frame=0x7ffffffe1aa0) at ./vm/gen/instruction_implementations.hpp:524
#23 0x00000000007f0386 in rubinius::BlockEnvironment::execute_interpreter (state=0x17ef8a0, previous=0x7ffffffe2e10, env=0x7ffff6945120, args=..., invocation=...) at vm/builtin/block_environment.cpp:340
#24 0x00000000007efe7a in rubinius::BlockEnvironment::invoke (state=0x17ef8a0, previous=0x7ffffffe2e10, env=0x7ffff6945120, args=..., invocation=...) at vm/builtin/block_environment.cpp:82
#25 0x00000000007f06ef in rubinius::BlockEnvironment::call_under (this=0x7ffff6945120, state=0x17ef8a0, call_frame=0x7ffffffe2e10, exec=0x7ffff5ebfed8, mod=0x18448e0, args=...) at vm/builtin/block_environment.cpp:396
#26 0x0000000000744816 in rubinius::Primitives::block_call_under (state=0x17ef8a0, call_frame=0x7ffffffe2e10, exec=0x7ffff5ebfed8, mod=0x18448e0, args=...) at vm/gen/method_primitives.cpp:2205
#27 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x17ef8a0, cache=0x1c56550, call_frame=0x7ffffffe2e10, args=...) at vm/inline_cache.cpp:592
#28 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x1c56550, state=0x17ef8a0, call_frame=0x7ffffffe2e10, args=...) at vm/inline_cache.hpp:197
#29 0x00000000006c1b35 in rubinius::MachineCode::interpreter (state=0x17ef8a0, mcode=0x1c551b0, call_frame=0x7ffffffe2e10) at ./vm/gen/instruction_implementations.hpp:524
#30 0x0000000000736ce9 in rubinius::MachineCode::execute_specialized (state=0x17ef8a0, previous=0x7ffffffe4130, exec=0x7ffff5fe6288, mod=0x18333b0, args=...) at vm/machine_code.cpp:630
#31 0x00000000006b9b68 in rubinius::InlineCache::empty_cache (state=0x17ef8a0, cache=0x29fab00, call_frame=0x7ffffffe4130, args=...) at vm/inline_cache.cpp:390
#32 0x00000000006bb9f4 in rubinius::InlineCache::initialize (this=0x29fab00, state=0x17ef8a0, call_frame=0x7ffffffe4130, args=...) at vm/inline_cache.hpp:201
#33 0x00000000006baaee in rubinius::InlineCache::check_cache_poly (state=0x17ef8a0, cache=0x29fab00, call_frame=0x7ffffffe4130, args=...) at vm/inline_cache.cpp:721
#34 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x29fab00, state=0x17ef8a0, call_frame=0x7ffffffe4130, args=...) at vm/inline_cache.hpp:197
0x7ffffffde550: Celluloid::IO::Reactor#shutdown in /home/dirkjan/rubinius/lib/19/forwardable.rb:182 (+34)
0x7ffffffdf730: Celluloid::IO::Mailbox#shutdown in /home/dirkjan/celluloid-io/lib/celluloid/io/mailbox.rb:75 (+5)
0x7ffffffe08c0: Celluloid::Actor.kill in /home/dirkjan/rubinius/gems/1.9/bundler/gems/celluloid-092c27e7676a/lib/celluloid/actor.rb:152 (+24)
0x7ffffffe1aa0: __block__ in /home/dirkjan/rubinius/gems/1.9/bundler/gems/celluloid-092c27e7676a/spec/support/actor_examples.rb:13 (+52)
0x7ffffffe2e10: BasicObject#instance_eval in kernel/common/eval19.rb:45 (+118)
0x7ffffffe4130: __block__ in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:113 (+36)
0x7ffffffe53a0: RSpec::Core::Example#with_around_each_hooks in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:253 (+21)
0x7ffffffe6590: RSpec::Core::Example#run in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:0 (+53)
0x7ffffffe7870: __block__ in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:378 (+41)
0x7ffffffe8ae0: Array#map in kernel/bootstrap/array19.rb:18 (+100)
0x7ffffffe9db0: RSpec::Core::ExampleGroup.run_examples in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:374 (+11)
0x7ffffffeb010: RSpec::Core::ExampleGroup.run in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:360 (+68)
0x7ffffffec2d0: __block__ in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361 (+8)
0x7ffffffed520: Array#map in kernel/bootstrap/array19.rb:18 (+100)
0x7ffffffee7e0: RSpec::Core::ExampleGroup.run in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361 (+82)
0x7ffffffefa10: __block__ in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361 (+8)
0x7fffffff0c60: Array#map in kernel/bootstrap/array19.rb:18 (+100)
0x7fffffff1e90: RSpec::Core::ExampleGroup.run in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:361 (+82)
0x7fffffff31a0: __block__ in /home/dirkjan/rubinius/gems/1.9/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28 (+8)
0x7fffffff43f0: Array#map in kernel/bootstrap/array19.rb:18 (+100)

For thread 13 these are the backtraces. You can also see that this is exactly the same selector object:

(gdb) thread 13
[Switching to thread 13 (Thread 0x7fffee2f9700 (LWP 18268))]
(gdb) frame 7
#7  NIO_Selector_select_synchronized (args=33385360) at selector.c:298
298     ready = NIO_Selector_run(selector, timeout);
(gdb) p selector
$1 = (struct NIO_Selector *) 0x2a2acd0

C++ backtrace:

#0  0x00007ffff6aa9a43 in epoll_wait () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff6aa9a43 in epoll_wait () from /usr/lib/libc.so.6
#1  0x00007fffee300802 in epoll_poll (loop=0x2a2ad60, timeout=) at ../libev/ev_epoll.c:153
#2  0x00007fffee2ffda2 in ev_backend_poll (ptr=) at ../libev/ev.c:2945
#3  0x00000000009357f3 in rb_thread_blocking_region (func=0x7fffee2ffd90 , data=0x7fffee2efd30, ubf=0xffffffffffffffff, ubf_data=0x0) at vm/capi/thread.cpp:135
#4  0x00007fffee302a74 in ev_run (loop=0x2a2ad60, flags=flags@entry=2) at ../libev/ev.c:3120
#5  0x00007fffee2fecd5 in ev_loop (loop=, flags=2) at ../libev/ev.h:820
#6  NIO_Selector_run (timeout=, selector=0x2a2acd0) at selector.c:338
#7  NIO_Selector_select_synchronized (args=33385360) at selector.c:298
#8  0x0000000000920bf2 in rb_ensure (func=0x7fffee2fec40 , arg1=33385360, ensure_func=0x7fffee2fe9e0 , arg2=33386032) at vm/capi/kernel.cpp:141
#9  0x00007fffee2ff2e2 in NIO_Selector_select (argc=1, argv=0x7fffee2eff60, self=33386032) at selector.c:280
#10 0x000000000083fc92 in rubinius::GenericArguments::invoke (state=0x7fffee2f8e40, nm=0x7ffff694a138, env=0x7fffd8005310, args=...) at vm/builtin/nativemethod.cpp:302
#11 0x0000000000843f4b in rubinius::NativeMethod::executor_implementation (state=0x7fffee2f8e40, call_frame=0x7fffee2f1790, exec=0x7ffff694a138, mod=0x283afe0, args=...) at vm/builtin/nativemethod.cpp:706
#12 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x7fffee2f8e40, cache=0x7fffd8002ab0, call_frame=0x7fffee2f1790, args=...) at vm/inline_cache.cpp:592
#13 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x7fffd8002ab0, state=0x7fffee2f8e40, call_frame=0x7fffee2f1790, args=...) at vm/inline_cache.hpp:197
#14 0x00000000006c1cdd in rubinius::MachineCode::interpreter (state=0x7fffee2f8e40, mcode=0x7fffd8002860, call_frame=0x7fffee2f1790) at ./vm/gen/instruction_implementations.hpp:542
#15 0x0000000000736ce9 in rubinius::MachineCode::execute_specialized (state=0x7fffee2f8e40, previous=0x7fffee2f2950, exec=0x7ffff68b4000, mod=0x282ea50, args=...) at vm/machine_code.cpp:630
#16 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x7fffee2f8e40, cache=0x7fffd8001888, call_frame=0x7fffee2f2950, args=...) at vm/inline_cache.cpp:592
#17 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x7fffd8001888, state=0x7fffee2f8e40, call_frame=0x7fffee2f2950, args=...) at vm/inline_cache.hpp:197
#18 0x00000000006c1b35 in rubinius::MachineCode::interpreter (state=0x7fffee2f8e40, mcode=0x7fffd8000ba0, call_frame=0x7fffee2f2950) at ./vm/gen/instruction_implementations.hpp:524
#19 0x0000000000736ce9 in rubinius::MachineCode::execute_specialized (state=0x7fffee2f8e40, previous=0x7fffee2f3b60, exec=0x7ffff68b44f8, mod=0x28151d0, args=...) at vm/machine_code.cpp:630
#20 0x00000000006ba536 in rubinius::InlineCache::check_cache_reference (state=0x7fffee2f8e40, cache=0x7fffe0004018, call_frame=0x7fffee2f3b60, args=...) at vm/inline_cache.cpp:592
#21 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x7fffe0004018, state=0x7fffee2f8e40, call_frame=0x7fffee2f3b60, args=...) at vm/inline_cache.hpp:197
#22 0x00000000006c1b35 in rubinius::MachineCode::interpreter (state=0x7fffee2f8e40, mcode=0x7fffe0003510, call_frame=0x7fffee2f3b60) at ./vm/gen/instruction_implementations.hpp:524
#23 0x0000000000737170 in rubinius::MachineCode::execute_specialized (state=0x7fffee2f8e40, previous=0x7fffee2f4df0, exec=0x7ffff4e360f8, mod=0x284f670, args=...) at vm/machine_code.cpp:630
#24 0x00000000006b9f86 in rubinius::InlineCache::empty_cache_vcall (state=0x7fffee2f8e40, cache=0x2827aa0, call_frame=0x7fffee2f4df0, args=...) at vm/inline_cache.cpp:472
#25 0x00000000006bb9f4 in rubinius::InlineCache::initialize (this=0x2827aa0, state=0x7fffee2f8e40, call_frame=0x7fffee2f4df0, args=...) at vm/inline_cache.hpp:201
#26 0x00000000006ba631 in rubinius::InlineCache::check_cache (state=0x7fffee2f8e40, cache=0x2827aa0, call_frame=0x7fffee2f4df0, args=...) at vm/inline_cache.cpp:615
#27 0x00000000006eb1ec in rubinius::InlineCache::execute (this=0x2827aa0, state=0x7fffee2f8e40, call_frame=0x7fffee2f4df0, args=...) at vm/inline_cache.hpp:197
#28 0x00000000006c19af in rubinius::MachineCode::interpreter (state=0x7fffee2f8e40, mcode=0x280f4b0, call_frame=0x7fffee2f4df0) at ./vm/gen/instruction_implementations.hpp:507
#29 0x00000000007f0386 in rubinius::BlockEnvironment::execute_interpreter (state=0x7fffee2f8e40, previous=0x7fffee2f6040, env=0x7ffff663a6a0, args=..., invocation=...) at vm/builtin/block_environment.cpp:340
#30 0x00000000007efe7a in rubinius::BlockEnvironment::invoke (state=0x7fffee2f8e40, previous=0x7fffee2f6040, env=0x7ffff663a6a0, args=..., invocation=...) at vm/builtin/block_environment.cpp:82
#31 0x00000000007f0444 in rubinius::BlockEnvironment::call (this=0x7ffff663a6a0, state=0x7fffee2f8e40, call_frame=0x7fffee2f6040, args=..., flags=0) at vm/builtin/block_environment.cpp:351
#32 0x00000000006c2e3a in rubinius::MachineCode::interpreter (state=0x7fffee2f8e40, mcode=0x27e9b80, call_frame=0x7fffee2f6040) at ./vm/gen/instruction_implementations.hpp:760
#33 0x00000000007f0386 in rubinius::BlockEnvironment::execute_interpreter (state=0x7fffee2f8e40, previous=0x7fffee2f74c0, env=0x7ffff663aa38, args=..., invocation=...) at vm/builtin/block_environment.cpp:340
#34 0x00000000007efe7a in rubinius::BlockEnvironment::invoke (state=0x7fffee2f8e40, previous=0x7fffee2f74c0, env=0x7ffff663aa38, args=..., invocation=...) at vm/builtin/block_environment.cpp:82
#35 0x00000000007f0444 in rubinius::BlockEnvironment::call (this=0x7ffff663aa38, state=0x7fffee2f8e40, call_frame=0x7fffee2f74c0, args=..., flags=0) at vm/builtin/block_environment.cpp:351

Ruby backtrace:

0x7fffee2f1790: Celluloid::IO::Reactor#run_once in /home/dirkjan/celluloid-io/lib/celluloid/io/reactor.rb:49 (+17)
0x7fffee2f2950: Celluloid::IO::Mailbox#receive in /home/dirkjan/celluloid-io/lib/celluloid/io/mailbox.rb:53 (+95)
0x7fffee2f3b60: Celluloid::Actor#run in /home/dirkjan/rubinius/gems/1.9/bundler/gems/celluloid-092c27e7676a/lib/celluloid/actor.rb:194 (+26)
0x7fffee2f4df0: __block__ in /home/dirkjan/rubinius/gems/1.9/bundler/gems/celluloid-092c27e7676a/lib/celluloid/actor.rb:184 (+38)
0x7fffee2f6040: __block__ in /home/dirkjan/rubinius/gems/1.9/bundler/gems/celluloid-092c27e7676a/lib/celluloid/thread_handle.rb:12 (+9)
0x7fffee2f74c0: __block__ in /home/dirkjan/rubinius/gems/1.9/bundler/gems/celluloid-092c27e7676a/lib/celluloid/internal_pool.rb:48 (+22)
0x7fffee2f8960: Thread#__run__ in kernel/bootstrap/thread19.rb:42 (+38)

Fail to build nio4r 5.0 on CentOS

Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
        ERROR: Failed to build gem native extension.

    /apps/ruby/ruby/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... yes
checking for sys/event.h... no
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR="
compiling monitor.c
In file included from nio4r.h:10,
                 from monitor.c:6:
/apps/ruby/ruby/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
In file included from nio4r.h:11,
                 from monitor.c:6:
libev.h:9:25: warning: no newline at end of file
monitor.c:217:2: warning: no newline at end of file
monitor.c:30: warning: ยฐร†NIO_Monitor_callbackยฐร˜ declared ยฐร†staticยฐร˜ but never defined
compiling nio4r_ext.c
In file included from nio4r.h:10,
                 from nio4r_ext.c:6:
/apps/ruby/ruby/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
In file included from nio4r.h:11,
                 from nio4r_ext.c:6:
libev.h:9:25: warning: no newline at end of file
In file included from nio4r_ext.c:7:
../libev/ev.c:481:48: warning: "/*" within comment
In file included from nio4r_ext.c:7:
../libev/ev.c:1535: warning: ยฐร†ev_default_loop_ptrยฐร˜ initialized and declared ยฐร†externยฐร˜
../libev/ev.c: In function ยฐร†array_nextsizeยฐร˜:
../libev/ev.c:1644: warning: comparison between signed and unsigned
In file included from ../libev/ev.c:2397,
                 from nio4r_ext.c:7:
../libev/ev_epoll.c: At top level:
../libev/ev_epoll.c:235: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_epoll.c:235: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
../libev/ev_epoll.c:260: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_epoll.c:260: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
../libev/ev_epoll.c:267: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_epoll.c:267: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
In file included from ../libev/ev.c:2400,
                 from nio4r_ext.c:7:
../libev/ev_poll.c:42: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_poll.c:42: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
../libev/ev_poll.c: In function ยฐร†poll_pollยฐร˜:
../libev/ev_poll.c:110: warning: left-hand operand of comma expression has no effect
../libev/ev_poll.c: At top level:
../libev/ev_poll.c:129: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_poll.c:129: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
../libev/ev_poll.c:142: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_poll.c:142: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
In file included from ../libev/ev.c:2403,
                 from nio4r_ext.c:7:
../libev/ev_select.c:274: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_select.c:274: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
../libev/ev_select.c:303: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev_select.c:303: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
In file included from nio4r_ext.c:7:
../libev/ev.c:2419: warning: ยฐร†staticยฐร˜ is not at beginning of declaration
../libev/ev.c:2419: warning: ยฐร†inlineยฐร˜ is not at beginning of declaration
../libev/ev.c: In function ยฐร†verify_watcherยฐร˜:
../libev/ev.c:2806: warning: left-hand operand of comma expression has no effect
../libev/ev.c:2809: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†verify_heapยฐร˜:
../libev/ev.c:2819: warning: left-hand operand of comma expression has no effect
../libev/ev.c:2820: warning: left-hand operand of comma expression has no effect
../libev/ev.c:2821: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†array_verifyยฐร˜:
../libev/ev.c:2832: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_verifyยฐร˜:
../libev/ev.c:2850: warning: left-hand operand of comma expression has no effect
../libev/ev.c:2863: warning: left-hand operand of comma expression has no effect
../libev/ev.c:2867: warning: left-hand operand of comma expression has no effect
../libev/ev.c:2868: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†timers_reifyยฐร˜:
../libev/ev.c:3050: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†periodics_reifyยฐร˜:
../libev/ev.c:3112: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_backend_pollยฐร˜:
../libev/ev.c:3257: warning: no return statement in function returning non-void
../libev/ev.c: In function ยฐร†ev_runยฐร˜:
../libev/ev.c:3274: warning: left-hand operand of comma expression has no effect
../libev/ev.c:3431: warning: ยฐร†rb_thread_blocking_regionยฐร˜ is deprecated (declared at /apps/ruby/ruby/include/ruby-2.0.0/ruby/intern.h:839)
../libev/ev.c:3446: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†clear_pendingยฐร˜:
../libev/ev.c:3564: warning: dereferencing type-punned pointer will break strict-aliasing rules
../libev/ev.c: In function ยฐร†ev_clear_pendingยฐร˜:
../libev/ev.c:3578: warning: dereferencing type-punned pointer will break strict-aliasing rules
../libev/ev.c: In function ยฐร†ev_io_startยฐร˜:
../libev/ev.c:3620: warning: left-hand operand of comma expression has no effect
../libev/ev.c:3621: warning: left-hand operand of comma expression has no effect
../libev/ev.c:3630: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_io_stopยฐร˜:
../libev/ev.c:3645: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_timer_startยฐร˜:
../libev/ev.c:3665: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_timer_stopยฐร˜:
../libev/ev.c:3693: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_periodic_startยฐร˜:
../libev/ev.c:3755: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_periodic_stopยฐร˜:
../libev/ev.c:3787: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_signal_startยฐร˜:
../libev/ev.c:3824: warning: left-hand operand of comma expression has no effect
../libev/ev.c:3827: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_child_startยฐร˜:
../libev/ev.c:3945: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_stat_startยฐร˜:
../libev/ev.c:4289: warning: dereferencing type-punned pointer will break strict-aliasing rules
../libev/ev.c: In function ยฐร†ev_embed_startยฐร˜:
../libev/ev.c:4524: warning: left-hand operand of comma expression has no effect
../libev/ev.c: In function ยฐร†ev_onceยฐร˜:
../libev/ev.c:4757: warning: dereferencing type-punned pointer will break strict-aliasing rules
../libev/ev.c:4873:27: warning: "/*" within comment
../libev/ev.c:4874:27: warning: "/*" within comment
compiling selector.c
In file included from nio4r.h:10,
                 from selector.c:6:
/apps/ruby/ruby/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
In file included from nio4r.h:11,
                 from selector.c:6:
libev.h:9:25: warning: no newline at end of file
In file included from selector.c:7:
/apps/ruby/ruby/include/ruby-2.0.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
selector.c: In function ยฐร†NIO_Selector_deregister_synchronizedยฐร˜:
selector.c:241: warning: unused variable ยฐร†monitor_argsยฐร˜
selector.c:240: warning: unused variable ยฐร†interestsยฐร˜
selector.c: In function ยฐร†NIO_Selector_selectยฐร˜:
selector.c:268: warning: unused variable ยฐร†arrayยฐร˜
selector.c: In function ยฐร†NIO_Selector_select_synchronizedยฐร˜:
selector.c:286: warn

OS and GCC version:

Linux version 2.6.18-274.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)) #1 SMP Fri Jul 8 17:36:59 EDT 2011

Build Issue on OS X 10.11 and Ruby 2.2.2

I'm having issues building nio4r on the latest version of OS X 10.11 and Ruby 2.2.2. Build log output here:

/usr/local/opt/rbenv/versions/2.2.2/bin/ruby -r ./siteconf20150714-44665-18sflk9.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling monitor.c
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:487:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1033:42: error: '_Noreturn' keyword must precede function declarator
  ecb_inline void ecb_unreachable (void) ecb_noreturn;
                                         ^~~~~~~~~~~~
  _Noreturn 
./../libev/ev.c:836:26: note: expanded from macro 'ecb_noreturn'
  #define ecb_noreturn   _Noreturn
                         ^
./../libev/ev.c:1629:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2494:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2900:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2903:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2913:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2914:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2915:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2926:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2944:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2957:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2961:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2962:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3144:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3206:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3368:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3539:9: warning: implicit declaration of function 'rb_thread_call_without_gvl' is invalid in C99 [-Wimplicit-function-declaration]
        rb_thread_call_without_gvl(ev_backend_poll, (void *)&poll_args, RUBY_UBF_IO, 0);
        ^
./../libev/ev.c:3554:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3728:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3729:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3738:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3740:34: warning: '&' within '|' [-Wbitwise-op-parentheses]
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                       ~~~~~~~~~~^~~~~~~~~~~~~ ~
./../libev/ev.c:3740:34: note: place parentheses around the '&' expression to silence this warning
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                                 ^
                       (                      )
./../libev/ev.c:3753:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3773:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3801:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3863:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3895:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3932:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3935:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4053:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4632:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
31 warnings and 1 error generated.
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

Error on windows x64: make failed, uncaught signal 11

Ruby 2.2.4 x64, devkit 4.7.2. 64bit

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    C:/Lavoro/Ruby/ruby-224x64/bin/ruby.exe -r ./siteconf20160409-96-m7y7ff.rb extconf.rb
checking for unistd.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... yes
checking for sys/select.h... no
checking for poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... no
checking for port.h... no
checking for sys/resource.h... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="

make failed, uncaught signal 11

Gem files will remain installed in C:/Lavoro/Ruby/ruby-224x64/lib/ruby/gems/2.2.0/gems/nio4r-1.2.1 for inspection.
Results logged to C:/Lavoro/Ruby/ruby-224x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/nio4r-1.2.1/gem_make.out

Fails to build on osx 10.9.2

I saw another post, but those fixes weren't helpful for me. Here are my logs.

Specs:
Macbook pro, 10.9.2
ruby version: 2.0.0p247
GCC Version:
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

Any direction would be really helpful, thanks.

sudo gem install nio4r
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
1 warning generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:481:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1535:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2806:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2809:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2819:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2820:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2821:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2832:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2850:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2863:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2867:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2868:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3050:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3112:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3257:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
./../libev/ev.c:3274:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3446:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3620:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3621:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3630:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3632:34: warning: '&' within '|' [-Wbitwise-op-parentheses]
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                       ~~~~~~~~~~^~~~~~~~~~~~~ ~
./../libev/ev.c:3632:34: note: place parentheses around the '&' expression to silence this warning
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                                 ^
                       (                      )
./../libev/ev.c:3645:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3665:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3693:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3755:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3787:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3824:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3827:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3945:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4524:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
32 warnings generated.
compiling selector.c
In file included from selector.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from selector.c:7:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubysig.h:14:2: warning: rubysig.h is obsolete [-W#warnings]
#warning rubysig.h is obsolete
 ^
selector.c:391:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:391:76: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                                                           ^~~~
                                                                           &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
selector.c:407:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:407:77: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                                                            ^~~~
                                                                            &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
6 warnings generated.
linking shared-object nio4r_ext.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [nio4r_ext.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nio4r-1.0.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nio4r-1.0.0/gem_make.out

Cannot compile C extension on OSX El Capitan with Ruby 2.0.0-p247

I'm getting the following output:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/omer.katz/.rvm/rubies/ruby-2.0.0-p247/bin/ruby -r ./siteconf20160411-83265-zn5369.rb extconf.rb
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/Users/omer.katz/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
1 warning generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:6:
In file included from ./nio4r.h:10:
/Users/omer.katz/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:481:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:974:42: error: '_Noreturn' keyword must precede function declarator
  ecb_inline void ecb_unreachable (void) ecb_noreturn;
                                         ^~~~~~~~~~~~
  _Noreturn
./../libev/ev.c:777:26: note: expanded from macro 'ecb_noreturn'
  #define ecb_noreturn   _Noreturn
                         ^
./../libev/ev.c:1535:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2806:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2809:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2819:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2820:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2821:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2832:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2850:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2863:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2867:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2868:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3050:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3112:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3274:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3431:9: warning: 'rb_thread_blocking_region' is deprecated [-Wdeprecated-declarations]
        rb_thread_blocking_region(ev_backend_poll, (void *)&poll_args, RUBY_UBF_IO, 0);
        ^
/Users/omer.katz/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/intern.h:839:18: note: 'rb_thread_blocking_region' has been explicitly marked deprecated here
DEPRECATED(VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
                 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3446:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3620:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3621:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3630:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3632:34: warning: '&' within '|' [-Wbitwise-op-parentheses]
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                       ~~~~~~~~~~^~~~~~~~~~~~~ ~
./../libev/ev.c:3632:34: note: place parentheses around the '&' expression to silence this warning
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                                 ^
                       (                      )
./../libev/ev.c:3645:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3665:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3693:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3755:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3787:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3824:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3827:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3945:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4524:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
32 warnings and 1 error generated.
make: *** [nio4r_ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/omer.katz/.rvm/gems/ruby-2.0.0-p247@tracking_service/gems/nio4r-1.0.0 for inspection.
Results logged to /Users/omer.katz/.rvm/gems/ruby-2.0.0-p247@tracking_service/extensions/x86_64-darwin-15/2.0.0/nio4r-1.0.0/gem_make.out

Native channels on JRuby don't work with JDK builtin selectors

There are a number of IO types in JRuby that don't come from the standard set of channels on the JDK. Primary example of this is UNIXSocket/Server, which are provided by jnr-unixsocket using jnr-enxio. jnr-enxio, because it uses FFI to perform all IO and selection operations, has its own provider and its own selectors.

In nio4r, selectors are always created using the default provider, so they will only work with channel types from that provider.

As a result, nio4r selectors do not work with JRuby's UNIXServer/Socket, and this is the root cause of jruby/jruby#2750.

The issue is further complicated by the use of IO.pipe channels to wake up the selector. IO.pipe channels in JRuby come from the default provider, and you can't use a single selector to handle channels from two different providers.

In JRuby, we mitigated this issue in our selector logic as follows:

  • If we're only selecting on one channel or multiple channels with the same provider, just get an appropriate selector for it from a pool. The pool is keyed off provider.
  • If we are selecting against channels from different providers, the enxio selection happens in a separate selector and thread with a pipe connecting it to the default provider and selector; this allows either selector to wake both.

It's not an ideal setup, but I think nio4r will need to duplicate this logic, or we need to expose the logic we have in JRuby more directly (i.e. not hidden behind IRubyObject wrangling).

Is `epoll` really being utilized?

I was reading through the code, since I ran into some issues with fd connection limits.

I noticed that the extconf.rb file defined DEV_USE_EPOLL but there doesn't deem to be any mention of the DEV_USE_EPOLL directive anywhere in the C code.

I suspect the nio4r gem might be using select (instead of epoll), which would explain some issues with fd limits and service crashes when using ActionCable.

Could you review or comment on this?

P.S.

The issue / question refers to Ubuntu 16.04

Error installing nio4r

C:\Sites>gem install nio4r -v 1.2.1
Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.

current directory: C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/nio4r-1.2.1/ext/nio4r

C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20160717-4636-1gzmau5.rb extconf.rb
checking for unistd.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/RailsInstaller/Ruby2.2.0/bin/$(RUBY_BASE_NAME)
C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:587:intry_cpp'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:1060:in block in have_header' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:911:inblock in checking_for'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in block (2 levels) in postpone' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:321:inopen'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in block in postpone' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:321:inopen'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:347:in postpone' from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:910:inchecking_for'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:1059:in have_header' from extconf.rb:3:in

'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/nio4r-1.2.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/nio4r-1.2.1 for inspection.
Results logged to C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/nio4r-1.2.1/gem_make.out

Behavioral difference between C and Pure implementation

I noticed this while reading the implementations. I'm not sure if it is intended behavior or not (or if the difference even matters), but I do find the behavior in the pure ruby version slightly peculiar.

The pure ruby implementation will return early if woken up. If there were some monitors ready as well they will not be returned: https://github.com/celluloid/nio4r/blob/master/lib/nio/selector.rb#L73

The C implementation will wake up, but will return all ready monitors of the select call if there were any. No early return.

Here's some code that will behave different depending on which implementation is used:

selector = NIO::Selector.new

r, w = IO.pipe

selector.register(r, :r)
selector.wakeup
w.write("\x0")

p selector.select { |m| m.io.read(1) }
p selector.select(1)

C implementation will print the ready monitor, and then nil (timeout).
Ruby implementation will print nil, and then the ready monitor.

Gem::InstallError: The 'nio4r' native gem requires installed build tools.

Edit; I just looked back through the closed issues and see this has come up before in #31
I apologise to say that this is still an issue for me. As you will see below, I am using Ruby 1.9.3 which apparently resolved some other peoples problem, so it seems odd I should be having it.
/-------------------------------------------------------------------------------------------------------------/

Please Note: I am new to Ruby/Gems/SASS
This is in a Windows 7 64 bit environment.

The Ruby download version is Ruby 1.9.3-p545
The Ruby DevKit download version is DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe

I have added the Ruby bin folder to PATH
Ruby installed OK (G:/Ruby)
Ruby Dev Toolkit Installed OK (G:/Ruby/DevKit)
PIK installed OK (G:/Pik)
I have a separate folder for a theme file , controlled by SASS (G:\Themes\gfnp4)
Problems start when I run 'bundle install ' from that folder

g:\Themes\gfnp4>bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Installing addressable 2.3.6
Installing chunky_png 1.3.0
Installing fssm 0.2.10
Installing sass 3.2.18
Installing compass 0.12.4
Installing breakpoint 2.0.7
Installing timers 1.1.0
Installing celluloid 0.15.2

Gem::InstallError: The 'nio4r' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing nio4r (1.0.0), and Bundler cannot continue.
Make sure that gem install nio4r -v '1.0.0' succeeds before bundling.
/------------------------------------------------------------------------/
I'm unsure what folder is being referred to by 'build tools' in the suggestion 'Please update your PATH to include build tools' so I tried the following :

I tried adding the DevKit folder to the Windows PATH variable which produced the same result.
I then repeated this adding DevKit/bin. A mass of new errors was thrown up , as follows :
/------------------------------------------------------------------------/
g:\Themes\gfnp4>bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using addressable 2.3.6
Using chunky_png 1.3.0
Using fssm 0.2.10
Using sass 3.2.18
Using compass 0.12.4
Using breakpoint 2.0.7
Using timers 1.1.0
Using celluloid 0.15.2

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
G:/Ruby/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
/------------------------------------------------------------------------/

Here are the contents of mkmf.log:

"gcc -o conftest -IG:/Ruby/include/ruby-1.9.1/i386-mingw32 -IG:/Ruby/include/ruby-1.9.1/ruby/backward -IG:/Ruby/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048 -DFD_SETSIZE=2048 -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LG:/Ruby/lib -L. -march=i486 -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp -lshlwapi "
In file included from G:/Ruby/include/ruby-1.9.1/ruby/ruby.h:1382,
from G:/Ruby/include/ruby-1.9.1/ruby.h:32,
from conftest.c:1:
G:/Ruby/include/ruby-1.9.1/ruby/missing.h:44: error: redefinition of 'struct timespec'
G:/Ruby/include/ruby-1.9.1/ruby/missing.h:51: error: redefinition of 'struct timezone'
checked program was:
/* begin _/
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char *_argv)
6: {
7: return 0;
8: }
/* end */

/------------------------------------------------------------------------/

It's possible that extconf.rb is not the issue and that there may be a problem with versions or that my environment isn't correctly set up (re. my comment earlier regarding what folder is being referred to by 'build tools').

I hope this gives enough info.

ruby2.3 rails 5.0,make error,why?

Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r

/usr/local/bin/ruby -r ./siteconf20160720-14029-ijtxf6.rb extconf.rb
checking for unistd.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/usr/local/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/nio4r-1.2.1/mkmf.log

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r
make "DESTDIR=" clean

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r
make "DESTDIR="
compiling monitor.c
compiling nio4r_ext.c
In file included from nio4r_ext.c:7:
./../libev/ev.c:487:48: warning: '/' within block comment [-Wcomment]
/
#define MIN_INTERVAL 0.00000095367431640625 /* 1/2*_20, good till 2200 */
^
./../libev/ev.c:1067:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'unsigned int' [-Wshorten-64-to-32]
return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
~~~~~~~~~~~~~~~~^~
./../libev/ev.c:929:49: note: expanded from macro 'ecb_popcount32'
#define ecb_popcount32(x) _builtin_popcount (x)
~~~~~~~~~~~~~~~~~~ ^
./../libev/ev.c:1273:13: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare]
if (e < (14 - 24)) /
might not be sharp, but is good enough /
~ ^ ~~~~~~~
./../libev/ev.c:1829:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /
needs to be initialised to make it a definition despite extern */
^
./../libev/ev.c:1916:7: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
EV_TV_SET (tv, delay);
^~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:492:64: note: expanded from macro 'EV_TV_SET'

define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)

                                                         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

./../libev/ev.c:1938:19: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4)
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:2280:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
k = minpos - heap;
~ ~~~~~~~^~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2688:
./../libev/ev_kqueue.c:115:34: warning: implicit conversion loses integer precision: 'uintptr_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
int fd = kqueue_events [i].ident;
~~ ~~~~~~~~~~~~~~~~~~^~~~~
./../libev/ev_kqueue.c:119:39: warning: implicit conversion loses integer precision: 'intptr_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
int err = kqueue_events [i].data;
~~~ ~~~~~~~~~~~~~~~~~~^~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2694:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2697:
./../libev/ev_select.c:109:24: warning: implicit conversion loses integer precision: 'unsigned long' to 'fd_mask' (aka 'int') [-Wshorten-64-to-32]
fd_mask mask = 1UL << (fd % NFDBITS);
~~~~ ~~~~^~~~~~~~~~~~~~~~~
./../libev/ev_select.c:147:3: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
EV_TV_SET (tv, timeout);
^~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:492:64: note: expanded from macro 'EV_TV_SET'

define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)

                                                         ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2697:
./../libev/ev_select.c:259:34: warning: implicit conversion loses integer precision: 'unsigned long' to 'fd_mask' (aka 'int') [-Wshorten-64-to-32]
fd_mask mask = 1UL << bit;
~~~~ ~~~~^~~~~~
In file included from nio4r_ext.c:7:
./../libev/ev.c:3100:12: warning: expression result unused [-Wunused-value]
assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3103:14: warning: expression result unused [-Wunused-value]
assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3113:16: warning: expression result unused [-Wunused-value]
assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3114:16: warning: expression result unused [-Wunused-value]
assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3115:16: warning: expression result unused [-Wunused-value]
assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3126:16: warning: expression result unused [-Wunused-value]
assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3144:14: warning: expression result unused [-Wunused-value]
assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3157:24: warning: expression result unused [-Wunused-value]
assert (("libev: io watcher list contains a loop", w != w2));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3161:20: warning: expression result unused [-Wunused-value]
assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3162:20: warning: expression result unused [-Wunused-value]
assert (("libev: fd mismatch between watcher and anfd", ((ev_io )w)->fd == i));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3344:24: warning: expression result unused [-Wunused-value]
assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3406:24: warning: expression result unused [-Wunused-value]
assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3568:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3752:22: warning: expression result unused [-Wunused-value]
assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3926:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_io_start called with negative fd", fd >= 0));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3927:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3936:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3951:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3971:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3999:14: warning: expression result unused [-Wunused-value]
assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4061:16: warning: expression result unused [-Wunused-value]
assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4093:14: warning: expression result unused [-Wunused-value]
assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4130:12: warning: expression result unused [-Wunused-value]
assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4133:12: warning: expression result unused [-Wunused-value]
assert (("libev: a signal must not be attached to two different loops",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4251:12: warning: expression result unused [-Wunused-value]
assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4830:14: warning: expression result unused [-Wunused-value]
assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
(builtin_expect(!(e), 0) ? __assert_rtn(__func, FILE, LINE, #e) : (void)0)
^
39 warnings generated.
compiling selector.c
selector.c:355:9: error: use of undeclared identifier 'TRAP_BEG'
TRAP_BEG;
^
selector.c:357:9: error: use of undeclared identifier 'TRAP_END'
TRAP_END;
^
selector.c:366:13: error: use of undeclared identifier 'TRAP_BEG'
TRAP_BEG;
^
selector.c:368:13: error: use of undeclared identifier 'TRAP_END'
TRAP_END;
^
4 errors generated.
make: *
* [selector.o] Error 1

make failed, exit code 2

jruby: not properly registering interests for IO coming from ffi(?)

I'm writing a ruby client for net-snmp using ffi and making it compatible with celluloid-io. For MRI, it has been working alright. I'm having issues with jruby 9k, though.

All the examples have been done using 9.1.1.0 (latest release). The following example works:

# example script of creating io object from fd and passing it to the selector
io = IO.for_fd 2 # stderrr
IO.select [], [io] #=> [], [io]
selector = NIO::Selector.new
selector.register(io, :w)

Problem is when I'm acting on a file descriptor coming from the snmp session structure. As it's all done in C, I'm "deep-fetching" from the structure and initializing an IO object, which would then be passed to the reactor.

...
require 'nio'
io = IO.for_fd(fd_from_the_snmp_structure)
# this works, btw
IO.select [], [io] #=> [], [io]

selector = NIO::Selector.new
selector.register(io, :w) #=>
ArgumentError: mode not supported for this object: r
  register at org/nio4r/Nio4r.java:172

as previously stated, it works under MRI. It might be a bug in jruby, it's a bit hard for me to figure out, problem seems however to be in the symbolToInterestOps in the java extension(?), possibly, maybe. Is the first such report, or do I have to dig a bit deeper?

Sporadic test failures on OS X

There are some random failures in the test suite related to readiness. When I ran the test suite sometimes IO objects are not instantly ready when expected to.

For example https://github.com/celluloid/nio4r/blob/master/spec/nio/selectables/tcp_socket_spec.rb#L83 fails because the selector.select(0) call sometimes return nil.

I've noticed about 4 or 5 of these failures in master. Unfortunately I'm having issues replicating all these failures on my development laptop, I believe it might be too slow and old to catch the race conditions.

Build warnings in ev.c

I saw these warnings compiling with VS 2013 on Windows 7:

c:\users\djberge\repositories\nio4r\ext\nio4r\../libev/ev.c(1156) : warning C4244: 'function' : conversion from 'int' to 'float', possible loss of data
c:\users\djberge\repositories\nio4r\ext\nio4r\../libev/ev.c(1157) : warning C4244: 'function' : conversion from 'int' to 'float', possible loss of data
c:\users\djberge\repositories\nio4r\ext\nio4r\../libev/ev.c(2266) : warning C4133: '=' : incompatible types - from 'WSABUF *' to 'CHAR *'
c:\users\djberge\repositories\nio4r\ext\libev\ev_select.c(200) : warning C4244: 'initializing' : conversion from 'ev_tstamp' to 'unsigned long', possible loss of data
c:\users\djberge\repositories\nio4r\ext\libev\ev.c(3351) : warning C4716: 'ev_backend_poll' : must return a value

Version 1.2.1 failing to install

I'm having trouble getting this package to install:

dwilt:gjs-server dwilt$ gem install nio4r -v '1.2.1'
Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
    ERROR: Failed to build gem native extension.

    current directory: /Users/dwilt/.rvm/gems/ruby-2.3.0/gems/nio4r-1.2.1/ext/nio4r
/Users/dwilt/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20161005-83288-o77xp1.rb extconf.rb
mkmf.rb can't find header files for ruby at /Users/dwilt/.rvm/rubies/ruby-2.3.0/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /Users/dwilt/.rvm/gems/ruby-2.3.0/gems/nio4r-1.2.1 for inspection.
Results logged to /Users/dwilt/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/nio4r-1.2.1/gem_make.out

Any ideas?

unclosed subscribe segfaults the rubyvm

cross Issue to (celluloid/celluloid-redis#8)
This sample will segfault the ruby vm:

require 'redis'
require 'celluloid/io'
require 'celluloid/redis'

    class Runner
        include Celluloid::IO
        attr_accessor :redis
        def initialize
            async.run
        end

        def run()
            @redis = ::Redis.new(:driver => :celluloid)
            @redis.subscribe("foo", "bar") {}
        end
    end
    r = Runner.new
    exit #crashes since r.redis is still subscribed

crash log for 1.9.3
https://gist.github.com/ranmrdrakono/304a07d514488b08c3be

ruby version:

ruby -v 
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

gem versions:

gem list --local

*** LOCAL GEMS ***
 [...]
celluloid (0.14.1)
celluloid-io (0.14.1)
celluloid-redis (0.0.2)
 [...]
nio4r (0.4.6)
 [...]
rubygems-bundler (1.2.0, 1.1.0)
rvm (1.11.3.8, 1.11.3.5)

also: problem remains in ruby2.0:
https://gist.github.com/ranmrdrakono/b48334e74e55d833a162

NullPointerExceptions occurring when monitors are being closed.

These seem to happen at random times, but most commonly when I'm shutting down my server. Stack trace for one of those included below. All occurrences go through Celluloid::IO::Reactor#wait(), but what is above that varies.

nio4r 1.2.1-java
Celluloid / Celluloid-IO 0.17.3
JRuby 9.0.1.0 / Java 1.8_0_72

Discussion of this issue started at https://groups.google.com/d/topic/celluloid-ruby/O9q9rHdtcy0

2016-02-16T12:52:46.244000 [ERROR]: CLEANUP CRASHED!
Java::JavaLang::NullPointerException:
    org.jruby.util.io.OpenFile.channel(OpenFile.java:2245)
    org.jruby.RubyIO.getChannel(RubyIO.java:403)
    org.nio4r.Nio4r$Selector.deregister(Nio4r.java:188)
    org.nio4r.Nio4r$Selector$INVOKER$i$1$0$deregister.call(Nio4r$Selector$INVOKER$i$1$0$deregister.gen)
    org.jruby.RubyClass.finvoke(RubyClass.java:756)
    org.jruby.runtime.Helpers.invoke(Helpers.java:400)
    org.jruby.RubyBasicObject.callMethod(RubyBasicObject.java:376)
    org.nio4r.Nio4r$Monitor.close(Nio4r.java:462)
    org.nio4r.Nio4r$Monitor.close(Nio4r.java:453)
    org.nio4r.Nio4r$Monitor$INVOKER$i$close.call(Nio4r$Monitor$INVOKER$i$close.gen)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:129)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.reactor.invokeOther53:close(<install/path>/celluloid-io-0.17.3/lib/celluloid/io/reactor.rb)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.reactor.RUBY$method$wait$0(<install/path>/celluloid-io-0.17.3/lib/celluloid/io/reactor.rb:52)
    org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:146)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:216)
    org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:205)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:193)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.reactor.invokeOther3:wait(<install/path>/celluloid-io-0.17.3/lib/celluloid/io/reactor.rb)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.reactor.RUBY$method$wait_readable$0(<install/path>/celluloid-io-0.17.3/lib/celluloid/io/reactor.rb:21)
    org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:131)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:181)
    org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:161)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.invokeOther14:wait_readable(<install/path>/celluloid-io-0.17.3/lib/celluloid/io.rb)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.RUBY$method$wait_readable$0(<install/path>/celluloid-io-0.17.3/lib/celluloid/io.rb:54)
    org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:131)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:181)
    org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
    org.jruby.internal.runtime.methods.WrapperMethod.call(WrapperMethod.java:59)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:161)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.tcp_server.invokeOther6:wait_readable(<install/path>/celluloid-io-0.17.3/lib/celluloid/io/tcp_server.rb)
    install.path.celluloid_minus_io_minus_0_dot_17_dot_3.lib.celluloid.io.tcp_server.RUBY$method$accept$0(<install/path>/celluloid-io-0.17.3/lib/celluloid/io/tcp_server.rb:36)
    org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:116)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:146)
    org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:189)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:129)
    org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:305)
    org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
    org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:136)
    org.jruby.runtime.InterpretedIRBlockBody.commonYieldPath(InterpretedIRBlockBody.java:118)
    org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:67)
    org.jruby.runtime.Block.yieldSpecific(Block.java:116)
    org.jruby.RubyKernel.loop(RubyKernel.java:1291)
    org.jruby.RubyKernel$INVOKER$s$0$0$loop.call(RubyKernel$INVOKER$s$0$0$loop.gen)
    org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroBlock.call(JavaMethod.java:494)
    org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:273)
    org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:79)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)
    org.jruby.ir.instructions.CallBase.interpret(CallBase.java:419)
    org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:321)
    org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:77)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:127)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:113)
    org.jruby.RubyClass.finvoke(RubyClass.java:541)
    org.jruby.RubyBasicObject.send19(RubyBasicObject.java:1626)
    org.jruby.RubyBasicObject$INVOKER$i$send19.call(RubyBasicObject$INVOKER$i$send19.gen)
    org.jruby.RubyKernel.public_send(RubyKernel.java:1823)
    org.jruby.RubyKernel$INVOKER$s$0$0$public_send.call(RubyKernel$INVOKER$s$0$0$public_send.gen)
    org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:77)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:83)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.calls.invokeOther6:public_send(<install/path>/celluloid-0.17.3/lib/celluloid/calls.rb)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.calls.RUBY$method$dispatch$0(<install/path>/celluloid-0.17.3/lib/celluloid/calls.rb:28)
    org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:101)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:111)
    org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuper(IRRuntimeHelpers.java:899)
    org.jruby.ir.runtime.IRRuntimeHelpers.instanceSuperSplatArgs(IRRuntimeHelpers.java:892)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.call.async.invokeSuper19:dispatch(<install/path>/celluloid-0.17.3/lib/celluloid/call/async.rb)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.call.async.RUBY$method$dispatch$0(<install/path>/celluloid-0.17.3/lib/celluloid/call/async.rb:7)
    org.jruby.internal.runtime.methods.CompiledIRMethod.call(CompiledIRMethod.java:131)
    org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:181)
    org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:197)
    org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:313)
    org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.cell.invokeOther13:dispatch(<install/path>/celluloid-0.17.3/lib/celluloid/cell.rb)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.cell.RUBY$block$dispatch$2(<install/path>/celluloid-0.17.3/lib/celluloid/cell.rb:50)
    org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
    org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:140)
    org.jruby.runtime.BlockBody.yield(BlockBody.java:77)
    org.jruby.runtime.Block.yield(Block.java:147)
    org.jruby.ir.runtime.IRRuntimeHelpers.yield(IRRuntimeHelpers.java:450)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.cell.RUBY$block$task$1(<install/path>/celluloid-0.17.3/lib/celluloid/cell.rb:76)
    org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
    org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:67)
    org.jruby.runtime.Block.yieldSpecific(Block.java:116)
    org.jruby.ir.runtime.IRRuntimeHelpers.yieldSpecific(IRRuntimeHelpers.java:457)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.actor.RUBY$block$task$1(<install/path>/celluloid-0.17.3/lib/celluloid/actor.rb:339)
    org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
    org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:67)
    org.jruby.runtime.Block.yieldSpecific(Block.java:116)
    org.jruby.ir.runtime.IRRuntimeHelpers.yieldSpecific(IRRuntimeHelpers.java:457)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.task.RUBY$block$initialize$2(<install/path>/celluloid-0.17.3/lib/celluloid/task.rb:44)
    org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
    org.jruby.runtime.IRBlockBody.yieldSpecific(IRBlockBody.java:67)
    org.jruby.runtime.Block.yieldSpecific(Block.java:116)
    org.jruby.ir.runtime.IRRuntimeHelpers.yieldSpecific(IRRuntimeHelpers.java:457)
    install.path.celluloid_minus_0_dot_17_dot_3.lib.celluloid.task.fibered.RUBY$block$create$2(<install/path>/celluloid-0.17.3/lib/celluloid/task/fibered.rb:14)
    org.jruby.runtime.CompiledIRBlockBody.commonYieldPath(CompiledIRBlockBody.java:70)
    org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:147)
    org.jruby.runtime.BlockBody.yield(BlockBody.java:83)
    org.jruby.runtime.Block.yieldArray(Block.java:161)
    org.jruby.ext.fiber.ThreadFiber$1.run(ThreadFiber.java:259)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    java.lang.Thread.run(Thread.java:745) 

How to merge from original libev 4.22 to nio4r bundled libev

Hi,
May I ask you a question?
I want to know how to create your nio4r bundled libev (nio4r/ext/libev/).
Because I want to use original version's libev 4.22 for nio4r.

The way is like this?

1. Download original source from this.
http://dist.schmorp.de/libev/

2. Set downloaded files to ext/libev/ .

3. Patch below below things in the case of 4.22.
[PATCH] Update to libev 4.22
https://github.com/celluloid/nio4r/commit/0d9b6a9.patch

Could you tell me how you are doing for each libev version up?

Thanks.

Fails to build on osx 10.9.2

Hi there.. it's really difficult issue in here. I have 2 apple computers, one is laptop and one is imac, both has same osx version which is 10.9.2. Both has same ruby version:

ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]

Only on iMac I have compilation failure. If there's anything else I can provide to you please tell me.

romans-imac:chef-starter Holms$ cat Gemfile
source 'https://rubygems.org'

gem "berkshelf", '>= 3.0.0.beta1'
gem "knife-solo"

I've got compilation error, which I don't have any clue what's going on. With gem I've got same output.

Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Using addressable 2.3.6
Using multipart-post 1.2.0
Using faraday 0.8.9
Using berkshelf-api-client 1.1.1
Using buff-extensions 0.5.0
Using hashie 2.0.5
Using varia_model 0.3.2
Using buff-config 0.4.0
Using buff-ruby_engine 0.1.0
Using buff-shell_out 0.1.1
Using minitar 0.5.4
Using sawyer 0.5.4
Using octokit 2.7.2
Using retryable 1.3.5
Using buff-ignore 1.1.1
Using timers 1.1.0
Using celluloid 0.15.2

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
1 warning generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:481:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1535:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2806:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2809:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2819:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2820:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2821:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2832:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2850:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2863:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2867:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2868:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3050:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3112:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3257:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
./../libev/ev.c:3274:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3446:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3620:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3621:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3630:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3632:34: warning: '&' within '|' [-Wbitwise-op-parentheses]
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                       ~~~~~~~~~~^~~~~~~~~~~~~ ~
./../libev/ev.c:3632:34: note: place parentheses around the '&' expression to silence this warning
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                                 ^
                       (                      )
./../libev/ev.c:3645:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3665:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3693:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3755:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3787:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3824:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3827:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3945:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4524:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
32 warnings generated.
compiling selector.c
In file included from selector.c:6:
In file included from ./nio4r.h:10:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from selector.c:7:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/backward/rubysig.h:14:2: warning: rubysig.h is obsolete [-W#warnings]
#warning rubysig.h is obsolete
 ^
selector.c:391:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:391:76: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                                                           ^~~~
                                                                           &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
selector.c:407:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:407:77: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                                                            ^~~~
                                                                            &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
6 warnings generated.
linking shared-object nio4r_ext.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [nio4r_ext.bundle] Error 1


Gem files will remain installed in /var/folders/7q/xmnbj5dd6gg3v7xhw9h7kv180000gn/T/bundler20140402-59059-1u9b1cm/nio4r-1.0.0/gems/nio4r-1.0.0 for inspection.
Results logged to /var/folders/7q/xmnbj5dd6gg3v7xhw9h7kv180000gn/T/bundler20140402-59059-1u9b1cm/nio4r-1.0.0/gems/nio4r-1.0.0/ext/nio4r/gem_make.out
An error occurred while installing nio4r (1.0.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '1.0.0'` succeeds before bundling.

Best Practice

Hi,

Right now I'm using

(read_sockets, write_sockets, errors) = IO.select([socket_client, socket_server])

For a proxy I made, ad I understand nio4r has a better option to handle such need.
Does it suppose to work like this:

socket_client
socket_server
monitor1 = selector.register(socket_client, :r)
monitor2 = selector.register(socket_server, :r)
ready = selector.select(5)
ready.each do |sockets|
    if sockets == monitor1
        puts "this is the client socket"
    elsif
        puts "this is the server socket"
    end
end

What will be the alternative to something like that in nio4r ?

Thanks,

JRuby with :rw monitors spins in an infinite loop

Using this code based on the echo server example:

#!/usr/bin/env ruby

$:.push File.expand_path('../../lib', __FILE__)
require 'nio'
require 'socket'

class EchoServer
  def initialize(host, port)
    @selector = NIO::Selector.new

    puts "Listening on #{host}:#{port}"
    @server = TCPServer.new(host, port)

    monitor = @selector.register(@server, :rw)
    monitor.value = proc { accept }
  end

  def run
    while true
      @selector.select { |monitor| monitor.value.call(monitor) }
    end
  end

  def accept
    socket = @server.accept
    _, port, host = socket.peeraddr
    puts "*** #{host}:#{port} connected"

    monitor = @selector.register(socket, :rw)
    monitor.value = proc { |m| handler(m) }
  end

  def handler(monitor)
    if monitor.readable?
      read(monitor.io)
    end
  end

  def read(socket)
    data = socket.read_nonblock(4096)
    socket.write_nonblock(data)
  rescue EOFError
    _, port, host = socket.peeraddr
    puts "*** #{host}:#{port} disconnected"

    @selector.deregister(socket)
    socket.close
  end
end

if $0 == __FILE__
  EchoServer.new("localhost", 1234).run
end
-> % jruby --version
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on OpenJDK 64-Bit Server VM 1.7.0_45-b31 [linux-amd64]

gem install nio4r -v '1.0.0' fails

This error occurred when I updated my Rails' Ruby version to 2.0.0. Any idea what I can do here?

gem install nio4r -v '1.0.0'
Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
    ERROR: Failed to build gem native extension.

    /Users/nikolajandersen/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150125-95007-10ebeah.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/Users/nikolajandersen/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
monitor.c:30:13: warning: unused function 'NIO_Monitor_callback' [-Wunused-function]
static void NIO_Monitor_callback(struct ev_loop *ev_loop, struct ev_io *io, int revents);
            ^
2 warnings generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:6:
In file included from ./nio4r.h:10:
/Users/nikolajandersen/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:481:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:841:25: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    return ecb_ctz32 (x >> shift) + shift;
           ~~~~~~~~~  ~~^~~~~~~~
./../libev/ev.c:877:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    return r + ecb_ld32 (x);
               ~~~~~~~~  ^
./../libev/ev.c:922:26: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
  return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
         ~~~~~~~~~~~~~~  ^
./../libev/ev.c:966:37: warning: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') [-Wshorten-64-to-32]
    return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32);
                       ~~~~~~~~~~~  ^
./../libev/ev.c:1535:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
./../libev/ev.c:1622:7: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
      EV_TV_SET (tv, delay);
      ^~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:486:64: note: expanded from macro 'EV_TV_SET'
#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
                                                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:1644:19: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
  if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4)
      ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:1706:7: warning: unused variable 'ocur_' [-Wunused-variable]
      array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2);
      ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:1717:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (W, rfeeds, rfeedmax, rfeedcnt + 1, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:1844:7: warning: unused variable 'ocur_' [-Wunused-variable]
      array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
      ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:1986:18: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
      k = minpos - heap;
        ~ ~~~~~~~^~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2394:
./../libev/ev_kqueue.c:50:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2394:
./../libev/ev_kqueue.c:115:34: warning: implicit conversion loses integer precision: 'uintptr_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
      int fd = kqueue_events [i].ident;
          ~~   ~~~~~~~~~~~~~~~~~~^~~~~
./../libev/ev_kqueue.c:119:39: warning: implicit conversion loses integer precision: 'intptr_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
          int err = kqueue_events [i].data;
              ~~~   ~~~~~~~~~~~~~~~~~~^~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:66:7: warning: unused variable 'ocur_' [-Wunused-variable]
      array_needsize (struct pollfd, polls, pollmax, pollcnt, EMPTY2);
      ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2403:
./../libev/ev_select.c:109:24: warning: implicit conversion loses integer precision: 'unsigned long' to 'fd_mask' (aka 'int') [-Wshorten-64-to-32]
    fd_mask mask = 1UL << (fd % NFDBITS);
            ~~~~   ~~~~^~~~~~~~~~~~~~~~~
./../libev/ev_select.c:147:3: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
  EV_TV_SET (tv, timeout);
  ^~~~~~~~~~~~~~~~~~~~~~~
./../libev/ev.c:486:64: note: expanded from macro 'EV_TV_SET'
#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
                                                             ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2403:
./../libev/ev_select.c:259:34: warning: implicit conversion loses integer precision: 'unsigned long' to 'fd_mask' (aka 'int') [-Wshorten-64-to-32]
              fd_mask mask = 1UL << bit;
                      ~~~~   ~~~~^~~~~~
In file included from nio4r_ext.c:7:
./../libev/ev.c:2806:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2809:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2819:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2820:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2821:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2832:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2850:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2863:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2867:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2868:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3050:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3112:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3274:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3446:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3620:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3621:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3630:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3645:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3665:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3671:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ANHE, timers, timermax, ev_active (w) + 1, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:3693:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3755:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3765:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ANHE, periodics, periodicmax, ev_active (w) + 1, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:3787:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3824:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3827:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3945:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4351:5: warning: unused variable 'ocur_' [-Wunused-variable]
    array_needsize (ev_idle *, idles [ABSPRI (w)], idlemax [ABSPRI (w)], active, EMPTY2);
    ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:4391:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ev_prepare *, prepares, preparemax, preparecnt, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:4429:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ev_check *, checks, checkmax, checkcnt, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:4524:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4576:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ev_fork *, forks, forkmax, forkcnt, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:4614:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
./../libev/ev.c:4659:3: warning: unused variable 'ocur_' [-Wunused-variable]
  array_needsize (ev_async *, asyncs, asyncmax, asynccnt, EMPTY2);
  ^
./../libev/ev.c:1668:22: note: expanded from macro 'array_needsize'
      int ecb_unused ocur_ = (cur);                                     \
                     ^
55 warnings generated.
compiling selector.c
In file included from selector.c:6:
In file included from ./nio4r.h:10:
/Users/nikolajandersen/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from selector.c:7:
/Users/nikolajandersen/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: rubysig.h is obsolete [-W#warnings]
#warning rubysig.h is obsolete
 ^
selector.c:240:21: warning: unused variable 'interests' [-Wunused-variable]
    VALUE self, io, interests, selectables, monitor;
                    ^
selector.c:241:11: warning: unused variable 'monitor_args' [-Wunused-variable]
    VALUE monitor_args[3];
          ^
selector.c:268:20: warning: unused variable 'array' [-Wunused-variable]
    VALUE timeout, array;
                   ^
selector.c:286:9: warning: unused variable 'i' [-Wunused-variable]
    int i, ready;
        ^
selector.c:341:9: error: use of undeclared identifier 'TRAP_BEG'
        TRAP_BEG;
        ^
selector.c:343:9: error: use of undeclared identifier 'TRAP_END'
        TRAP_END;
        ^
selector.c:352:13: error: use of undeclared identifier 'TRAP_BEG'
            TRAP_BEG;
            ^
selector.c:354:13: error: use of undeclared identifier 'TRAP_END'
            TRAP_END;
            ^
selector.c:391:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:391:76: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                                                           ^~~~
                                                                           &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
selector.c:407:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:407:77: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                                                            ^~~~
                                                                            &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
10 warnings and 4 errors generated.
make: *** [selector.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/nikolajandersen/.rvm/gems/ruby-2.2.0/gems/nio4r-1.0.0 for inspection.
Results logged to /Users/nikolajandersen/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0/nio4r-1.0.0/gem_make.out

Support ruby 2.2.X (specifically on OS X)

Since the documentation does not say anything about supporting Ruby 2.2.X, I figured I'd start an issue to try and get this resolved.

After entering these commands on OS X 10.10 (and can reproduce in 10.9)

rbenv install 2.2.1
rbenv local 2.2.1
gem install nio4r

I get this stack trace while building native extensions.

Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
    ERROR: Failed to build gem native extension.

    /Users/wanelo/.rbenv/versions/2.2.1/bin/ruby -r ./siteconf20150908-74370-19l5j9y.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling monitor.c
In file included from monitor.c:6:
In file included from ./nio4r.h:10:
/Users/wanelo/.rbenv/versions/2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
1 warning generated.
compiling nio4r_ext.c
In file included from nio4r_ext.c:6:
In file included from ./nio4r.h:10:
/Users/wanelo/.rbenv/versions/2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:481:48: warning: '/*' within block comment [-Wcomment]
/*#define MIN_INTERVAL  0.00000095367431640625 /* 1/2**20, good till 2200 */
                                               ^
./../libev/ev.c:1535:31: warning: 'extern' variable has an initializer [-Wextern-initializer]
  EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */
                              ^
In file included from nio4r_ext.c:7:
In file included from ./../libev/ev.c:2400:
./../libev/ev_poll.c:110:18: warning: expression result unused [-Wunused-value]
        assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2806:12: warning: expression result unused [-Wunused-value]
  assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2809:14: warning: expression result unused [-Wunused-value]
    assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2819:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch in heap", ev_active (ANHE_w (heap [i])) == i));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2820:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap condition violated", i == HEAP0 || ANHE_at (heap [HPARENT (i)]) <= ANHE_at (heap [i])));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2821:16: warning: expression result unused [-Wunused-value]
      assert (("libev: heap at cache mismatch", ANHE_at (heap [i]) == ev_at (ANHE_w (heap [i]))));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2832:16: warning: expression result unused [-Wunused-value]
      assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2850:14: warning: expression result unused [-Wunused-value]
    assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2863:24: warning: expression result unused [-Wunused-value]
              assert (("libev: io watcher list contains a loop", w != w2));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2867:20: warning: expression result unused [-Wunused-value]
          assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:2868:20: warning: expression result unused [-Wunused-value]
          assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3050:24: warning: expression result unused [-Wunused-value]
              assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3112:24: warning: expression result unused [-Wunused-value]
              assert (("libev: ev_periodic reschedule callback returned time in the past", ev_at (w) >= ev_rt_now));
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3274:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3446:22: warning: expression result unused [-Wunused-value]
            assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w)));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3620:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with negative fd", fd >= 0));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3621:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE))));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3630:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3632:34: warning: '&' within '|' [-Wbitwise-op-parentheses]
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                       ~~~~~~~~~~^~~~~~~~~~~~~ ~
./../libev/ev.c:3632:34: note: place parentheses around the '&' expression to silence this warning
  fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
                                 ^
                       (                      )
./../libev/ev.c:3645:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3665:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3693:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3755:16: warning: expression result unused [-Wunused-value]
      assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.));
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3787:14: warning: expression result unused [-Wunused-value]
    assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3824:12: warning: expression result unused [-Wunused-value]
  assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3827:12: warning: expression result unused [-Wunused-value]
  assert (("libev: a signal must not be attached to two different loops",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:3945:12: warning: expression result unused [-Wunused-value]
  assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
In file included from nio4r_ext.c:7:
./../libev/ev.c:4524:14: warning: expression result unused [-Wunused-value]
    assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
31 warnings generated.
compiling selector.c
In file included from selector.c:6:
In file included from ./nio4r.h:10:
/Users/wanelo/.rbenv/versions/2.2.1/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
In file included from selector.c:7:
/Users/wanelo/.rbenv/versions/2.2.1/include/ruby-2.2.0/ruby/backward/rubysig.h:14:2: warning: rubysig.h is obsolete [-W#warnings]
#warning rubysig.h is obsolete
 ^
selector.c:341:9: error: use of undeclared identifier 'TRAP_BEG'
        TRAP_BEG;
        ^
selector.c:343:9: error: use of undeclared identifier 'TRAP_END'
        TRAP_END;
        ^
selector.c:352:13: error: use of undeclared identifier 'TRAP_BEG'
            TRAP_BEG;
            ^
selector.c:354:13: error: use of undeclared identifier 'TRAP_END'
            TRAP_END;
            ^
selector.c:391:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:391:76: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_close_synchronized, self);
                                                                           ^~~~
                                                                           &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
selector.c:407:43: warning: incompatible pointer types passing 'VALUE (VALUE)' to parameter of type 'VALUE (*)(VALUE *)' [-Wincompatible-pointer-types]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
selector.c:157:59: note: passing argument to parameter 'func' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                          ^
selector.c:407:77: warning: incompatible integer to pointer conversion passing 'VALUE' (aka 'unsigned long') to parameter of type 'VALUE *' (aka 'unsigned long *'); take the address with & [-Wint-conversion]
    return NIO_Selector_synchronize(self, NIO_Selector_closed_synchronized, self);
                                                                            ^~~~
                                                                            &
selector.c:157:86: note: passing argument to parameter 'args' here
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
                                                                                     ^
6 warnings and 4 errors generated.
make: *** [selector.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/wanelo/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/nio4r-1.0.0 for inspection.
Results logged to /Users/wanelo/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-13/2.2.0-static/nio4r-1.0.0/gem_make.out

I may try to work through this and get it working, but I figured if anyone else was interested I'd post an issue here!

This also happens w/ ruby 2.2.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.