Sha256: 50882b16e8a5674a0e1b4a244ec57cf9187db6e7e66d31c8825f1a3ac02b1c04
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
# -*- encoding: binary -*- # Copyright (C) 2009-2013, Eric Wong <normalperson@yhbt.net> et. al. # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require 'sendfile' module Yahns::WbufCommon # :nodoc: # returns nil on success, :wait_*able when blocked # currently, we rely on each thread having exclusive access to the # client socket, so this is never called concurrently with wbuf_write def wbuf_flush(client) case rv = client.trysendfile(@tmpio, @sf_offset, @sf_count) when Integer return wbuf_close(client) if (@sf_count -= rv) == 0 # all sent! @sf_offset += rv # keep going otherwise when :wait_writable, :wait_readable return rv when nil # response got truncated, drop the connection # this may happens when using Rack::File or similar, we can't # keep the connection alive because we already sent our Content-Length # header the client would be confused. @wbuf_persist = false return wbuf_close(client) else raise "BUG: rv=#{rv.inspect} " \ "on tmpio=#{@tmpio.inspect} " \ "sf_offset=#@sf_offset sf_count=#@sf_count" end while true end def wbuf_close_common(client) @body.close if @body.respond_to?(:close) if @wbuf_persist.respond_to?(:call) # hijack client.response_hijacked(@wbuf_persist) # :ignore else @wbuf_persist # true or false or Yahns::StreamFile end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
yahns-1.1.0 | lib/yahns/wbuf_common.rb |
yahns-1.0.0 | lib/yahns/wbuf_common.rb |
yahns-0.0.3 | lib/yahns/wbuf_common.rb |
yahns-0.0.2 | lib/yahns/wbuf_common.rb |