diff options
| author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-20 20:33:50 +0000 |
|---|---|---|
| committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-20 20:33:50 +0000 |
| commit | f7c3b6ff720e6084d578fe9e1a6c62bd80321d63 (patch) | |
| tree | 3cc5b2607e85c5b02842cd087034593e6ff30a51 /include/ruby | |
| parent | 8754f619d51a67fc4df255c189c8ff744433dd6e (diff) | |
io.c: IO.copy_stream uses poll on Linux
poll and ppoll have a superior API which doesn't require the
kernel to scan a potentially large bitmap to find a high-numbered
FD [ruby-core:35572]. So favor using poll in case IO.copy_stream
encounters a non-blocking FD.
We cannot reliably use poll on most OSes, because file types (e.g.
FIFOs) which work with select may not work with poll. Fortunately,
Linux uses a common notification mechanism between all
select/poll/epoll variants, so all file types are equally supported
between the notification mechanisms.
Verified by watching strace on the following scripts:
*** maygvl_copy_stream_wait_read ***
require 'io/nonblock'
r, w = IO.pipe
r.nonblock = true
IO.copy_stream(r, "/dev/null")
*** nogvl_copy_stream_wait_write ***
require 'io/nonblock'
r, w = IO.pipe
w.nonblock = true
IO.copy_stream("/dev/zero", w)
* io.c (nogvl_wait_for_single_fd): new function for Linux
(maygvl_copy_stream_wait_read): Linux-specific version
(nogvl_copy_stream_wait_write): use nogvl_wait_for_single_fd
[ruby-core:70051] [Feature #11377]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby')
0 files changed, 0 insertions, 0 deletions
