switch from IO#sendfile_nonblock to IO#trysendfile
[rainbows.git] / lib / rainbows / stream_file.rb
blob4a77a2f3d981da83ffa4e1fefa24190cf12b6853
1 # -*- encoding: binary -*-
2 # :enddoc:
4 # Used to keep track of file offsets in IO#trysendfile + evented
5 # models.  We always maintain our own file offsets in userspace because
6 # because sendfile() implementations offer pread()-like idempotency for
7 # concurrency (multiple clients can read the same underlying file handle).
8 class Rainbows::StreamFile < Struct.new(:offset, :count, :to_io, :body)
9   def close
10     body.close if body.respond_to?(:close)
11     to_io.close unless to_io.closed?
12     self.to_io = nil
13   end
14 end