Module: Yahns::WbufCommon
- Included in:
- StreamFile, Wbuf, WbufStr
- Defined in:
- lib/yahns/wbuf_common.rb
Overview
:nodoc:
Instance Method Summary collapse
- #wbuf_close_common(client) ⇒ Object
-
#wbuf_flush(client) ⇒ Object
returns true / false for persistent/non-persistent connections returns :wait_*able when blocked returns :ignore if hijacked currently, we rely on each thread having exclusive access to the client socket, so this is never called concurrently with wbuf_write.
Instance Method Details
#wbuf_close_common(client) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/yahns/wbuf_common.rb', line 43 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 |
#wbuf_flush(client) ⇒ Object
returns true / false for persistent/non-persistent connections returns :wait_*able when blocked returns :ignore if hijacked currently, we rely on each thread having exclusive access to the client socket, so this is never called concurrently with wbuf_write
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yahns/wbuf_common.rb', line 17 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 @sf_count > 0 wbuf_close(client) rescue wbuf_close(client) raise end |