Sha256: 8191d3f57f6703d31f4b46d763cba82551927f7d746c456b2c1b93815aadf0e4
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# -*- encoding: binary -*- # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> et. al. # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require_relative 'wbuf_common' class Yahns::StreamFile # :nodoc: include Yahns::WbufCommon # do not use this in your app (or any of our API) NeedClose = Class.new(File) # :nodoc: def initialize(body, persist, offset, count) if body.respond_to?(:to_io) @tmpio = body.to_io else path = body.to_path if path =~ %r{\A/dev/fd/(\d+)\z} @tmpio = IO.for_fd($1.to_i) @tmpio.autoclose = false else retried = false begin @tmpio = NeedClose.open(path) rescue Errno::EMFILE, Errno::ENFILE raise if retried retried = true Thread.current[:yahns_fdmap].desperate_expire_for(nil, 5) sleep(1) retry end end end @sf_offset = offset @sf_count = count || @tmpio.stat.size @wbuf_persist = persist # whether or not we keep the connection alive @body = body end # called by last wbuf_flush def wbuf_close(client) @tmpio.close if NeedClose === @tmpio wbuf_close_common(client) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yahns-0.0.2 | lib/yahns/stream_file.rb |