MRI 1.8 thread fix to avoid blocking accept()
commit7dde8d1402a44e2997fa86ff5e3cf89c4ca6d82a
authorEric Wong <normalperson@yhbt.net>
Mon, 1 Mar 2010 10:29:01 +0000 (1 10:29 +0000)
committerEric Wong <normalperson@yhbt.net>
Mon, 1 Mar 2010 10:29:01 +0000 (1 10:29 +0000)
tree47c38ac71b65068c845481b2efe1e37d3adfbcdb
parent168bacbea266baecafe72adc1d7fa08674607744
MRI 1.8 thread fix to avoid blocking accept()

Rainbows! commit ee7fe220ccbc991e1e7cbe982caf48e3303274c7

Under MRI 1.8, listen sockets do not appear to have the
nonblocking I/O flag on by default, nor does it set the
nonblocking I/O flag when calling #accept (but it does
when using #accept_nonblock, of course).

Normally this is not a problem even when using green threads
since MRI will internally select(2) on the file descriptor
before attempting a blocking (and immediately successful)
accept(2).

However, when sharing a listen descriptor across multiple
processes, spurious wakeups are likely to occur, causing
multiple processes may be woken up when a single client
connects.

This causes a problem because accept(2)-ing on multiple
threads/processes for a single connection causes blocking accepts in
multiple processes, leading to stalled green threads.

This is not an issue under 1.9 where a blocking accept() call
unlocks the GVL to let other threads run.
lib/zbatery.rb