rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 42368a1375fba67944b0df49fc6fd6af5813a6b9 480 bytes (raw)
$ git show v0.97.0:lib/rainbows/rev/sendfile.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 
# -*- encoding: binary -*-
# :enddoc:
module Rainbows::Rev::Sendfile
  if IO.method_defined?(:sendfile_nonblock)
    def rev_sendfile(sf) # +sf+ is a Rainbows::StreamFile object
      sf.offset += (n = @_io.sendfile_nonblock(sf, sf.offset, sf.count))
      0 == (sf.count -= n) and raise EOFError
      enable_write_watcher
      rescue Errno::EAGAIN
        enable_write_watcher
    end
  else
    def rev_sendfile(body)
      write(body.to_io.sysread(0x4000))
    end
  end
end

git clone https://yhbt.net/rainbows.git