diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-05 08:07:03 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-05 08:07:03 +0000 |
commit | 70ad994ae8a854477e45c877cd0e9dda41389f86 (patch) | |
tree | 9985ad0b56eda5e72341987255640cf9e34411b3 /lib/rainbows/rev/sendfile.rb | |
parent | 39b178cdebe275cbc8ce19cf269bea7cd15ff4ca (diff) | |
download | rainbows-70ad994ae8a854477e45c877cd0e9dda41389f86.tar.gz |
We need to load sendfile-using parts after the "sendfile" library is loaded.
Diffstat (limited to 'lib/rainbows/rev/sendfile.rb')
-rw-r--r-- | lib/rainbows/rev/sendfile.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/rainbows/rev/sendfile.rb b/lib/rainbows/rev/sendfile.rb new file mode 100644 index 0000000..9ab28bd --- /dev/null +++ b/lib/rainbows/rev/sendfile.rb @@ -0,0 +1,15 @@ +# -*- encoding: binary -*- +module Rainbows::Rev::Sendfile + if IO.method_defined?(:sendfile_nonblock) + def rev_sendfile(body) + body.pos += @_io.sendfile_nonblock(body, body.pos, 0x10000) + rescue Errno::EAGAIN + ensure + enable_write_watcher + end + else + def rev_sendfile(body) + write(body.sysread(0x4000)) + end + end +end |